This directive is used to prevent the user from installing new versions of an application while the application is still running, and to prevent the user from uninstalling a running application. It specifies the names of one or more named mutexes (multiple mutexes are separated by commas), which Setup and Uninstall will check for at startup. If any exist, Setup/Uninstall will display the message: "[Setup or Uninstall] has detected that [AppName] is currently running. Please close all instances of it now, then click OK to continue, or Cancel to exit." The value may include constants.
Use of this directive requires that you add code to your application which creates a mutex with the name you specify in this directive. Examples of creating a mutex in Delphi, C, and Visual Basic are shown below. The code should be executed during your application's startup.
Delphi:
CreateMutex(nil, False, 'MyProgramsMutexName');
C:
CreateMutex(NULL, FALSE, "MyProgramsMutexName");
Visual Basic (submitted by Peter Young):
'Place in Declarations section: Private Declare Function CreateMutex Lib "kernel32" _ Alias "CreateMutexA" _ (ByVal lpMutexAttributes As Long, _ ByVal bInitialOwner As Long, _ ByVal lpName As String) As Long 'Place in startup code (Form_Load or Sub Main): CreateMutex 0&, 0&, "MyProgramsMutexName"
It is not necessary to explicitly destroy the mutex object upon your application's termination; the system will do this automatically. Nor is it recommended that you do so, because ideally the mutex object should exist until the process completely terminates.
Note that mutex name comparison in Windows is case sensitive.
To specify a mutex name containing a comma, escape the comma with a backslash.
See the topic for CreateMutex in the MS SDK help for more information on mutexes.
AppMutex=MyProgramsMutexName,Global\MyProgramsMutexName
See also:
SetupMutex
CloseApplications