撤消或回滚安装

发布于 2024-11-14 16:13:34 字数 705 浏览 2 评论 0原文

我想在 AfterInstall 功能失败时在 IS 中执行回滚。这是我的代码示例。

[Files]
   Source: "MyWinService.exe"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall:     MyAfterInstall
   Source: "MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion
[Code]
   const
    WM_CLOSE = $0010;
   procedure MyAfterInstall();
   var
     exitCode: Integer;
   begin
      MsgBox (ExpandConstant('{cm:ErrServiceInstall}'), mbError, MB_OK);
      SendMessage(WizardForm.Handle, WM_CLOSE, 0, 0);
   end;

在这个示例中,我只是想直接取消安装,以便测试安装的回滚。这里发生的情况是,MsgBox显示后,由于SendMessage而显示ExitSetupMsgBox。当我在 ExitSetupMsgBox 中单击 Yes 时,将执行回滚。我想要的是 ExitSetupMsgBox 不显示,因为我已经显示了 MsgBox。因此,当我在 MsgBox 中单击“确定”时,将执行回滚。

这可以做到吗?

I want to perform rollback in IS when my AfterInstall function fails. Here is a sample of my Code.

[Files]
   Source: "MyWinService.exe"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall:     MyAfterInstall
   Source: "MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion
[Code]
   const
    WM_CLOSE = $0010;
   procedure MyAfterInstall();
   var
     exitCode: Integer;
   begin
      MsgBox (ExpandConstant('{cm:ErrServiceInstall}'), mbError, MB_OK);
      SendMessage(WizardForm.Handle, WM_CLOSE, 0, 0);
   end;

In this sample, I just directly want to cancel installation so to test rollback of installation. What happens here is that after MsgBox is displayed, ExitSetupMsgBox is displayed due to the SendMessage. When I click Yes in ExitSetupMsgBox, rollback will be performed. What I want is that ExitSetupMsgBox not displayed since I have already the MsgBox displayed. So when I clicked OK in MsgBox rollback will be performed.

Can this be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

青芜 2024-11-21 16:13:34

您可以使用事件 CancelButtonClick 来关闭确认对话框。

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Cancel := True;
  Confirm := False;
end;

您只需关闭 WizardForm 即可触发取消方法,无需发送特殊消息,只需调用即可。 WizardForm.Close 这是我所知道的在 AfterInstall 事件期间取消安装的唯一方法。

则此操作将不起作用。

[setup]
AllowCancelDuringInstall=no

注意:如果您使用/NOCANCEL 命令行选项运行安装程序,

You could use the Event CancelButtonClick where you can turn of of the confirmation dialog.

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Cancel := True;
  Confirm := False;
end;

You can trigger the cancel method by just closing the WizardForm, no need to send a special message just call. WizardForm.Close This is the only method I know of to cancel the install during an AfterInstall Event.

Note: This will not work if you have

[setup]
AllowCancelDuringInstall=no

or run your setup with the /NOCANCEL command line option.

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