【问题标题】:Handling and customizing errors and messages in Inno Setup在 Inno Setup 中处理和自定义错误和消息
【发布时间】:2021-05-04 21:38:20
【问题描述】:

Inno Setup 将向用户显示不同的消息框。 例如,

  1. 当它尝试安装一个正在使用的文件时,它会显示一条消息以中止/忽略/取消。

  2. 安装程序在安装文件时,安装时目标路径空间不足,安装程序会报错。

我需要自己自定义这些消息框。 (我不希望将这些本地消息显示给用户)例如,我需要显示另一个消息框,甚至完全不显示来自 Inno Setup 的特定消息,或者在该消息将要触发时更改标签.

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    所有 Inno Setup 消息都可以使用 [Messages] section 进行自定义。

    一些例子:


    关于消息框布局/设计的改变。你无法真正改变它。通过CheckBeforeInstall parameters 的一些奇特实现,您可能能够在 Inno Setup 检测到问题之前捕获一些问题并以自定义方式处理它们。但这样的工作量很大,结果并不可靠。

    如果您更具体地告诉我们您想要达到的目标,您可能会得到更具体的答案。


    如果您需要一个解决方案来允许 Inno Setup 出错时允许的所有操作,包括彻底中止安装,CheckBeforeInstall 将无济于事,因为他们没有办法彻底中止它。

    您必须在安装前进行所有检查,例如在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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 2013-09-23
      • 2013-12-04
      • 1970-01-01
      相关资源
      最近更新 更多