Search code examples
inno-setuppascalscript

Code to run after all files are installed with Inno Setup


I got the following little function which I need to call after all files of the [Files] section have been copied

procedure DllAfterInstall(platform: Integer);
begin
    if not installDriver(platform) then
                MsgBox(ExpandConstant('{cm:installDriverFail}'), mbError, MB_OK);
end;

where installDriver(platform) is an external function to one of my dll's.

As soon as I try to call the DllAfterInstall function in the [Run] section like

Filename: "{code:DllAfterInstall}"; Parameters: 0; Check: not IsWin64

I got the error

Invalid prototype for 'DllAfterInstall'

So can anyone tell me what I'm doing wrong? Or maybe is there another way to call a *.dll after all files have been copied? The *.dll function should only be called once so AfterInstall is no option.


Solution

  • Call your code from CurStepChanged event function when CurStep is ssPostInstall:

    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if CurStep = ssPostInstall then
      begin
        Log('Post install');
        DllAfterInstall(platform);
      end;
    end;
    

    You also need to provide an actual value to the platform parameter of the function.