GetActiveOleObject - 异常:操作不可用

发布于 2024-12-29 08:01:11 字数 878 浏览 1 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

真心难拥有 2025-01-05 08:01:11

根据以下新闻组帖子:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文