如何在没有提示的情况下正确退出Inno Setup向导? [英] How to properly close out of Inno Setup wizard without prompt?

查看:98
本文介绍了如何在没有提示的情况下正确退出Inno Setup向导?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的安装程序的一部分会在我们的服务器上检查最新版本,并在必要时在欢迎页面之后自动下载.实际的检查和下载位于函数CheckForNewInstaller中,如果已下载并执行了新安装程序,则该函数返回True,如果需要继续,则返回False.如果下载了新安装程序(True),则向导需要关闭.

Part of my installer checks for a latest version on our server and downloads automatically if necessary, just after the welcome page. The actual check and download are in a function CheckForNewInstaller which returns True if new installer was downloaded and has executed, and False if it needs to continue. If the new installer was downloaded (True) then the wizard needs to shut down.

使用以下代码,我已经使用WizardForm.Close完成了此操作.但是,它仍然会提示用户是否确定要取消.在正常情况下,我仍然希望用户在尝试关闭安装程序时得到此提示.但是,当我需要强制关闭向导时,需要隐藏此对话框.我也不能终止该过程,因为清理过程不会正确进行.

Using the following code, I have done this using WizardForm.Close. However, it still prompts the user if they're sure they wish to cancel. In normal scenarios, I still want the user to get this prompt if they attempt to close the installer. However, I need to suppress this dialog when I need to forcefully close the wizard. I also cannot be terminating the process, because the cleanup process wouldn't happen properly.

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
  X: Integer;
begin
  Log('NextButtonClick(' + IntToStr(CurPageID) + ') called');
  Result := True;
  case CurPageID of
    wpWelcome: begin
      if CheckForNewInstaller then begin
        //Need to close this installer as new one is starting
        WizardForm.Close;
      end;
    end;
    ....
  end;
end;

如何在没有任何进一步用户交互的情况下完全关闭此安装程序?

How can I close this installer completely down without any further user interaction?

推荐答案

这可以通过处理CancelButtonClick事件并设置Confirm参数来实现.

This can be done by handling the CancelButtonClick event and setting the Confirm parameter...

var
  ForceClose: Boolean;

procedure Exterminate;
begin
  ForceClose:= True;
  WizardForm.Close;  
end;

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

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
  X: Integer;
begin
  Log('NextButtonClick(' + IntToStr(CurPageID) + ') called');
  Result := True;
  case CurPageID of
    wpWelcome: begin
      if CheckForNewInstaller then begin
        Exterminate;
      end;
    end;
    ....
  end;
end;

这篇关于如何在没有提示的情况下正确退出Inno Setup向导?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆