Detect if an application is running

From ISXKB

(Difference between revisions)
Jump to: navigation, search
(category case)
Current revision (18:21, 11 November 2007) (view source)
(spelling)
 
Line 1: Line 1:
There are many ways to do that, looking for a mutex, a class, a window or a runnnig exe.
There are many ways to do that, looking for a mutex, a class, a window or a runnnig exe.
-
See also [http://www.jrsoftware.org/iskb.php?mutexsessions HOWTO: Detect instances running in any user session with AppMutex on Inno Setup Knowledge Base].  
+
See also [http://www.jrsoftware.org/iskb.php?mutexsessions HOWTO: Detect instances running in any user session with AppMutex on the Inno Setup Knowledge Base].  
__TOC__
__TOC__
-
== Checking for a Mutex ==
+
== 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.
Every GUI application should create a mutex on startup. [[Application considerations]] explains this in a bit more detail and points out additional considerations.
Line 27: Line 27:
To examine which mutexes are created by an application that you haven't developed yourself you can use [http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/ProcessExplorer.mspx ProcessExplorer].
To examine which mutexes are created by an application that you haven't developed yourself you can use [http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/ProcessExplorer.mspx ProcessExplorer].
-
== Checking for a Class Name ==
+
== Checking for a Window class name ==
It is possible to use
It is possible to use
   
   
-
  function FindWindowByClassName(const ClassName: String): Longint;  
+
  function FindWindowByClassName (const ClassName: String): Longint;  
-
and get window handle if found. It is possible to use this handle to send window messages.
+
and get a window handle if found. It is possible to use this handle to send window messages.
-
== Checking for a Window Name ==
+
== Checking for a Window name ==
Instaed of class it is possible to find a window if an application looking for windowname.  
Instaed of class it is possible to find a window if an application looking for windowname.  
-
  function FindWindowByWindowName(const WindowName: String): Longint;
+
  function FindWindowByWindowName (const WindowName: String): Longint;
== Checking for a running executable file ==  
== Checking for a running executable file ==  

Current revision

There are many ways to do that, looking for a mutex, a class, a window or a runnnig exe.

See also HOWTO: Detect instances running in any user session with AppMutex on the Inno Setup Knowledge Base.


Contents


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.

[Setup]
AppMutex=MyMutexName

This is the recommended way.

See the topic Application is running in the article Application considerations and Inno Setup's help file for more info. No further action is required in the script.

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.

See also

External links

Personal tools
Ads: