Detect if an application is running
There are many ways to do that, looking for a mutex, a class, a window or a runnnig exe.
Checking for a mutex
Every GUI application should create a mutex on startup. Application considerations explains this in a bit more detail and points out additional considerations.
Inno Setup can easily check the application's mutex if the 'AppMutex' directive is added to the script's [Setup] section.
This is the recommended way.
However, it is also possible to use
function CheckForMutexes (Mutexes: String): Boolean;
to check for a specified mutex from a [Code] section.
To examine which mutexes are created by an application that you haven't developed yourself you can use ProcessExplorer.
Checking for a Window class name
It is possible to use
function FindWindowByClassName (const ClassName: String): Longint;
and get a window handle if found. It is possible to use this handle to send window messages.
Checking for a Window name
Instaed of class it is possible to find a window if an application looking for windowname.
function FindWindowByWindowName (const WindowName: String): Longint;
Checking for a running executable file
You can use PSVince to detect if an executable is currently running.
- Application considerations
- Application is running in the article Application considerations
- Files in use extension