如何根据 InitializeSetup 后的检查以静默模式退出安装
How to exit from installation in silent mode based on a check after InitializeSetup
我正在尝试做类似于 this 的事情。
- 显示欢迎页面后进行版本检查
- 在降级和退出的情况下显示消息框(带有 mbInformation,MB_OK)
这适用于 UI 模式 - 安装程序退出。但是,在 /Silent 模式下,它显示消息框,但在单击“确定”按钮后继续。
能否请您建议如何在静默模式下实现类似的功能(即优雅地退出设置)
执行先决条件检查的静默模式没有区别。如果您想停止安装,只需在 InitializeSetup
event function 和 return False
中测试您的先决条件。
静默安装唯一需要考虑的事情是:
- 使用
SuppressibleMsgBox
function for error messages, instead of the plain MsgBox
. This way the message can be suppressed with the /suppressmsgboxes
command-line switch.
- 对于非常静默的安装,完全不显示消息框 (
/verysilent
)。
另见 How to detect whether the setup runs in very silent mode?
function WizardVerySilent: Boolean;
var
i: Integer;
begin
Result := False;
for i := 1 to ParamCount do
if CompareText(ParamStr(i), '/verysilent') = 0 then
begin
Result := True;
Break;
end;
end;
function InitializeSetup(): Boolean;
var
Message: string;
begin
Result := True;
if IsDowngrade then
begin
Message := 'Downgrade detected, aborting installation';
if not WizardVerySilent then
begin
SuppressibleMsgBox(Message, mbError, MB_OK, IDOK);
end
else
begin
Log(Message);
end;
Result := False;
end;
end;
我正在尝试做类似于 this 的事情。
- 显示欢迎页面后进行版本检查
- 在降级和退出的情况下显示消息框(带有 mbInformation,MB_OK)
这适用于 UI 模式 - 安装程序退出。但是,在 /Silent 模式下,它显示消息框,但在单击“确定”按钮后继续。
能否请您建议如何在静默模式下实现类似的功能(即优雅地退出设置)
执行先决条件检查的静默模式没有区别。如果您想停止安装,只需在 InitializeSetup
event function 和 return False
中测试您的先决条件。
静默安装唯一需要考虑的事情是:
- 使用
SuppressibleMsgBox
function for error messages, instead of the plainMsgBox
. This way the message can be suppressed with the/suppressmsgboxes
command-line switch. - 对于非常静默的安装,完全不显示消息框 (
/verysilent
)。
另见 How to detect whether the setup runs in very silent mode?
function WizardVerySilent: Boolean;
var
i: Integer;
begin
Result := False;
for i := 1 to ParamCount do
if CompareText(ParamStr(i), '/verysilent') = 0 then
begin
Result := True;
Break;
end;
end;
function InitializeSetup(): Boolean;
var
Message: string;
begin
Result := True;
if IsDowngrade then
begin
Message := 'Downgrade detected, aborting installation';
if not WizardVerySilent then
begin
SuppressibleMsgBox(Message, mbError, MB_OK, IDOK);
end
else
begin
Log(Message);
end;
Result := False;
end;
end;