2
votes

I am new to Inno Setup and having difficulty find this answer...

I have included a DirectX9 setup file in the installer, but I want to display a MessageBox to the user to ask "Do you want to install DirectX9?" that is done before the regular installation of my game... if he says yes, then I want to run this additional file that I included, but otherwise just proceed to install the game.

2
This question is very similar to this: stackoverflow.com/questions/12027679/inno-setup-compiler - Slappy

2 Answers

4
votes

The following code will run just before the installation begins. It asks for confirmation from the user and then runs "InstallDirectX.exe" (which must be available to the installer).

[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;
3
votes

If you want to display message box when installation finished, you can use this code:

[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;