At the very beginning of the script I have these lines of code:
#define ISSI_Splash "C:\InnoSetupProject\Images\client.bmp"
#define ISSI_Splash_T 3
#define ISSI_Splash_X 500
#define ISSI_Splash_Y 220
In my [Setup]
section I add the directive:
AppMutex=ABClientLaunchMutex
Then in the [Code]
section I create the mutex:
[Code]
function ISSI_InitializeSetup : Boolean;
begin
Result := True;
CreateMutex('ABClientLaunchMutex');
end;
#define ISSI_InitializeSetup
and those 2 lines of code are at the end of the script:
#define ISSI_IncludePath "C:\ISSI"
#include ISSI_IncludePath+"\_issi.isi"
But this does not work as one would expect. Whenever I launch the installer it immediately shows me the mutex's message that my apllication is already running, but this is not true. I haven't created my mutex in the Global namespace, so I don't need to use the Global\
prefix.
If I comment those 4 #define
directives at the beginning then the mutex won't work at all.
Could you please tell me what is wrong with my code so it works like that?
And I need to use the AppMutex if want to prevent the installer from running if my application is already installed and launched.
I think your mistake is that you are creating the mutex within the setup script itself when your application should be doing this.
I have AppMutex
only once in my script:
[setup]
AppMutex=xxxyyyzzz
As the documentation states:
Use of this directive requires that you add code to your application which creates a mutex with the name you specify in this directive.
The documentation provides example. Here is how I do it with a Visual C++ MFC project:
BOOL CMeetingScheduleAssistantApp::InitInstance()
{
CString strMutex;
stMutex.LoadString(IDS_APP_MUTEX);
m_hMutex = ::CreateMutex(nullptr, FALSE, strMutex);
...
...
}