Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup Checking for running process

Tags:

inno-setup

I have a Inno Setup project that I want to check if the application is actually running before uninstalling it. I tried many ways but it all fails silently, when running in Windows 7. For example the following script that checks for notepad.exe process using psvince.dll always returns false regardless of Notepad being running or not.

I used psvince.dll in a C# app to check, if it works under Windows 7 and it works without any problem. So my best guess is that installer can not run correctly with UAC enabled.

[Code]
function IsModuleLoaded(modulename: String): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall';

function InitializeSetup(): Boolean;
begin
   if(Not IsModuleLoaded('ePub.exe')) then
   begin
       MsgBox('Application is not running.', mbInformation, MB_OK);
       Result := true;
   end
   else
   begin
       MsgBox('Application is already running. Close it before uninstalling.', mbInformation, MB_OK);
       Result := false;
   end
end;
like image 722
Hadi Eskandari Avatar asked Mar 02 '10 12:03

Hadi Eskandari


People also ask

How do I make an inno file executable?

Step 1: Download inno setup software. Step 2: Choose Create new script file using the Script Wizard. Step 3: Fill Application Information. Step 4: Add files and folders and click on Next.

What does Inno Setup do?

The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX's and type libraries, and install fonts. Creation of shortcuts anywhere, including in the Start Menu and on the desktop. Creation of registry and . INI entries.

Does Inno setup work on Linux?

You're in luck: It's possible to run Inno Setup anywhere that Docker runs (including Linux and macOS), and even have a passable experience writing your setup script.


1 Answers

Are you using Unicode Inno Setup? If you are, it should say

function IsModuleLoaded(modulename: AnsiString): Boolean;

since psvince.dll isn't a Unicode dll.

Also the example checks for epub.exe, not notepad.exe.

like image 197
mlaan Avatar answered Oct 09 '22 18:10

mlaan