我的安装程序的一部分会在我们的服务器上检查最新版本,并在必要时在欢迎页面之后自动进行下载。实际的检查和下载位于一个函数中,该函数CheckForNewInstaller
返回True
是否已下载并执行了新的安装程序以及False
是否需要继续。如果下载了新的安装程序(True
),则向导需要关闭。
使用以下代码,我已使用完成此操作WizardForm.Close
。但是,它仍然会提示用户是否确定要取消。在正常情况下,我仍然希望用户在尝试关闭安装程序时得到此提示。但是,当我需要强制关闭向导时,需要隐藏该对话框。我也不能终止该过程,因为清理过程不会正确进行。
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;
如何在没有任何进一步用户交互的情况下完全关闭此安装程序?
这可以通过处理CancelButtonClick
事件并设置Confirm
参数来完成。
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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句