【问题标题】:Inno Setup - Display MessageBox to run additional fileInno Setup - 显示 MessageBox 以运行附加文件
【发布时间】:2012-08-19 15:25:03
【问题描述】:

我是 Inno Setup 的新手,很难找到这个答案...

我在安装程序中包含了一个 DirectX9 安装文件,但我想向用户显示一个 MessageBox 来询问“你想安装 DirectX9 吗?”这是在常规安装我的游戏之前完成的...如果他说是,那么我想运行我包含的这个附加文件,否则就继续安装游戏。

【问题讨论】:

标签: inno-setup


【解决方案1】:

以下代码将在安装开始之前运行。它要求用户确认,然后运行“InstallDirectX.exe”(安装程序必须可用)。

[Code]

function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ResultCode: integer;
begin
  if (msgbox('Do you want to install DirectX ?', mbConfirmation, MB_YESNO) = IDYES) then
  begin
    if Exec(ExpandConstant('InstallDirectX.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      // handle success if necessary; ResultCode contains the exit code
      MsgBox('Everything is proceeding according to plan', mbInformation, MB_OK);
    end
    else
    begin
      // handle failure if necessary; ResultCode contains the error code
      MsgBox('Something went horribly wrong', mbError, MB_OK);
    end;
  end;
end;

【讨论】:

    【解决方案2】:

    如果你想在安装完成后显示消息框,你可以使用这个代码:

    [Code]
    
    procedure CurStepChanged(CurStep: TSetupStep);
    var
      ResultCode: Integer;
    begin
       if CurStep = ssPostInstall then
       begin
          if (msgbox('Do you want to install DirectX ?', mbConfirmation, MB_YESNO) = IDYES) then
            begin
               if Exec(ExpandConstant('{src}\dxwebsetup.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
               begin
                  MsgBox('Installing DirectX completed', mbInformation, MB_OK);
               end
               else
               begin
                  MsgBox('Installing Error', mbError, MB_OK);
               end;
           end; 
       end;
    end;
    

    【讨论】:

    • +1 - 虽然 Inno Setup 具有这种工作流程的内置功能 - Tasks - 不需要如此复杂的实现。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 2011-03-30
    相关资源
    最近更新 更多