GetActiveOleObject - 异常:操作不可用
我的 Inno Setup
遇到问题,它给出了异常 Operation Unavailable
。
我什至尝试使用 Inno Setup
提供的示例代码 CodeAutomation.iss
,但它仍然给我同样的错误。如何让 GetActiveOleObject
正常工作?我错过了什么吗?
这是 Inno Setup
示例中的代码:
{--- Word ---}
procedure WordButtonOnClick(Sender: TObject);
var
Word: Variant;
begin
if MsgBox('Setup will now check whether Microsoft Word is running. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
Exit;
{ Try to get an active Word COM Automation object }
try
//This is where the error occurs.
Word := GetActiveOleObject('Word.Application');
except
end;
if VarIsEmpty(Word) then
MsgBox('Microsoft Word is not running.', mbInformation, mb_Ok)
else
MsgBox('Microsoft Word is running.', mbInformation, mb_Ok)
end;
提前致谢!
I'm have trouble with my Inno Setup
, it gives me the exception Operation Unavailable
.
I even tried using the example code CodeAutomation.iss
provided by Inno Setup
and it still is giving me the same error. How do I get GetActiveOleObject
to work? Am I missing something?
This is the code in the Inno Setup
example:
{--- Word ---}
procedure WordButtonOnClick(Sender: TObject);
var
Word: Variant;
begin
if MsgBox('Setup will now check whether Microsoft Word is running. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
Exit;
{ Try to get an active Word COM Automation object }
try
//This is where the error occurs.
Word := GetActiveOleObject('Word.Application');
except
end;
if VarIsEmpty(Word) then
MsgBox('Microsoft Word is not running.', mbInformation, mb_Ok)
else
MsgBox('Microsoft Word is running.', mbInformation, mb_Ok)
end;
Thanks ahead of time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据以下新闻组帖子:
http://news.jrsoftware.org/news/innosetup/ msg71386.html
http://news.jrsoftware.org/news/innosetup/msg71387.html
这是设计使然,仅在通过 IDE 运行时才会发生。运行编译的安装程序时是否出现错误?我刚刚在 Win7 SP1 x64 机器上尝试了 CodeAutomation.iss 中的代码,它工作正常。
According to the following newsgroup postings:
http://news.jrsoftware.org/news/innosetup/msg71386.html
http://news.jrsoftware.org/news/innosetup/msg71387.html
This is by design and only happens when run through the IDE. Are you getting the error when running a compiled setup? I just tried the code from CodeAutomation.iss on a Win7 SP1 x64 machine and it worked correctly.