2

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

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

4

2 回答 2

4

以下代码将在安装开始之前运行。它要求用户确认,然后运行“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;
于 2013-07-28T07:51:27.630 回答
3

如果要在安装完成后显示消息框,可以使用以下代码:

[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;
于 2016-11-06T09:39:25.850 回答