2

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.

user1610157
  • 61
  • 1
  • 5
  • 3
    This question is very similar to this: http://stackoverflow.com/questions/12027679/inno-setup-compiler – Slappy Aug 20 '12 at 05:04

2 Answers2

4

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Clever boy
  • 41
  • 3
3

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • +1 - Though Inno Setup has built-in functionality for this kind of workflow - [Tasks](http://www.jrsoftware.org/ishelp/index.php?topic=taskssection) - No need for such complicated implementation. – Martin Prikryl Nov 06 '16 at 12:05