撤消或回滚安装
我想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用事件
CancelButtonClick
来关闭确认对话框。您只需关闭 WizardForm 即可触发取消方法,无需发送特殊消息,只需调用即可。
WizardForm.Close
这是我所知道的在AfterInstall
事件期间取消安装的唯一方法。则此操作将不起作用。
注意:如果您使用/NOCANCEL 命令行选项运行安装程序,
You could use the Event
CancelButtonClick
where you can turn of of the confirmation dialog.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 anAfterInstall
Event.Note: This will not work if you have
or run your setup with the /NOCANCEL command line option.