Better prevention of multiple instances #507
Reported by jteh on 2009-12-10 03:02
We still need to use the window to detect old versions and also to send WM_QUIT to terminate an existing copy. However, we can use semaphores as an extra protection mechanism. Checking for and creating a semaphore is an atomic operation; creation will fail if it already exists. As soon as creating the semaphore fails, we know there is an existing copy.
Comment 1 by jteh on 2011-02-11 19:06
We can use CreateMutex and check for ERROR_ALREADY_EXISTS to determine if the app is already running. This way, both creation and check are atomic. The mutex name must include the desktop name, as we still want instances on other desktops to run.
This may have some impact on the service, so this needs to be tested.