Problem : Inno Setup – “Runime Error (at5:16) Could not call proc.”

Problem : Inno Setup – “Runime Error (at5:16) Could not call proc.”

I have written a small win32 DLL called ‘OLScan.dll’ which is able to check if MS Outlook is currently running. This DLL exposes a single function using the ‘stdcall’ calling convention and it returns a Boolean.

I have tested this dll from a separate exe and it works. However when I try and use it in Inno Setup script it only works for the install phase of the program and fails on the un-install with the error message “Runtime Error (at5:16) Could not call proc.” I have included my Inno Setup script which compiles without error.

Could someone please help me understand why the DLL call fails during the un-install phase?

Inno Setup Script
—————–

[Setup]
AppName = MyApp
AppVerName = MyApp v1.0
OutputBaseFilename = MyApp_v1
DefaultDirName = {pf}MyApp
OutputDir = _Setup

[Files]
; Add-in dll
Source: “MyApp.dll”;DestDir: “{app}”; Flags: regserver
;dll to check if outlook is loaded
Source: “OLScan.dll”;DestDir: “{app}”; Flags: dontcopy

const
MB_ICONINFORMATION = $40;

//Function to check if Outlook is loaded
function IsProcess():Boolean;
external ‘IsProcess@files:OLScan.dll stdcall’;

function NextButtonClick(CurPage: Integer): Boolean;
var
ok : Boolean;
begin
if CurPage = wpWelcome then begin
ok := IsProcess();
if ok then
begin
MsgBox(‘MS Outlook is loaded – please close MS Outlook before proceeding.’, mbError, MB_OK);
Result := false;
end
else
Result := True;
end
else
Result := True;
end;

function InitializeUninstall(): Boolean;
var
ok :Boolean;
begin

ok := IsProcess();
UnloadDLL(ExpandConstant(‘{app}OLScan.dll’))
if ok then
begin
MsgBox(‘MS Outlook is loaded – please close MS Outlook before proceeding.’, mbError, MB_OK);
Result := False;
end
else
Result := True;
end;


 

Solution: Inno Setup – “Runime Error (at5:16) Could not call proc.”

Looking at this example:-

http://raz-soft.com/display-english-posts-only/files-in-use-extension-for-inno-setup/

The programmer here created two separate declarations, one specifically for Install, the other specifically for uninstall.  Note the addition of {app} in the uninstall coding.

// IssFindModule called on install
function IssFindModule(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
external ‘IssFindModule@files:IssProc.dll stdcall setuponly’;

// IssFindModule called on uninstall
function IssFindModuleU(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
external ‘IssFindModule@{app}IssProc.dll stdcall uninstallonly’;