I try to run the application only once on the computer. My application should communicate in a web service, so itโs nice to let it run more than once, currently im using Mutex with this:
MyMsg := RegisterWindowMessage('My_Unique_App_Message_Name'); Mutex := CreateMutex(nil, True, 'My_Unique_Application_Mutex_Name'); if (Mutex = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) then exit;
This currently works to limit 1 instance of the application for each user, but my application is used in a Windows Server environment, where more than 20 users are registered at the same time, so I need them to be executed only once on the server, I'm trying to declare that Mutex like a global mutex, but I canโt do this, when I do the following code, it doesnโt work at all.
MyMsg := RegisterWindowMessage('My_Unique_App_Message_Name'); Mutex := CreateMutex(nil, True, 'Global\My_Unique_Application_Mutex_Name'); if (Mutex = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) then begin exit
So am I doing something wrong? is there any other reliable way not to allow the launch of the second instance of my application?
source share