GetActiveOleObject - 异常:操作不可用

时间:2012-01-26 20:20:42

标签: inno-setup pascal

我的Inno Setup出现问题,它给了我例外Operation Unavailable

我甚至尝试使用CodeAutomation.iss提供的示例代码Inno Setup,它仍然给我同样的错误。如何让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;

提前致谢!

1 个答案:

答案 0 :(得分:2)

根据以下新闻组帖子:

http://news.jrsoftware.org/news/innosetup/msg71386.html

http://news.jrsoftware.org/news/innosetup/msg71387.html

这是设计使然,仅在通过IDE运行时才会发生。运行编译设置时是否收到错误?我刚刚在Win7 SP1 x64机器上尝试了CodeAutomation.iss的代码,它运行正常。