问题描述
我需要自己定制这些消息框。 (我不希望向用户显示这些本机消息)例如,我需要显示另一个消息框,甚至完全不显示来自 Inno Setup 的特定消息,或者在该消息即将触发时更改标签.
解决方法
所有 Inno Setup 消息都可以使用 [Messages]
section 进行自定义。
一些例子:
- How to modify error message in Inno Setup?
- Show a custom message for unsupported architectures
- How can I show my own message and then exit setup if the current version of Windows is not supported?
至于消息框布局/设计的变化。你无法真正改变它。通过 Check
和 BeforeInstall
parameters 的一些奇特实现,您可能能够在 Inno Setup 检测到问题并以自定义方式处理它们之前发现一些问题。但这是大量工作,结果不可靠。
如果您更具体地告诉我们您想实现什么目标,您可能会得到更具体的答案。
如果您需要一个允许 Inno Setup 允许的所有错误的解决方案,包括安装的干净中止,Check
或 BeforeInstall
将无济于事,因为它们没有办法干净地中止
您必须在安装前进行所有检查,例如在CurStepChanged(ssInstall)
。
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Check: ShouldInstallFile
[Code]
var
DontInstallFile: Boolean;
function ShouldInstallFile: Boolean;
begin
Result := not DontInstallFile;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
FileName: string;
Msg: string;
Response: Integer;
begin
if CurStep = ssInstall then
begin
FileName := ExpandConstant('{app}\MyProg.exe');
repeat
if FileExists(FileName) and (not DeleteFile(FileName)) then
begin
Msg := Format('File %s cannot be replaced',[FileName]);
Response := MsgBox(Msg,mbError,MB_ABORTRETRYIGNORE)
case Response of
IDABORT: Abort;
IDIGNORE: DontInstallFile := True;
end;
end;
until (Response <> IDRETRY);
end;
end;