Original Post
Heya, as the topic says, i'm trying to restrict my application to only run once. Meaning i only want one instance running at a time. To achieve this, i'm using a Mutex as the following: But this wont work for me, GetLastError () never returns ERROR_ALREADY_EXISTS regardless how many instances allready running. Any ideas ? Impz0r
HANDLE hMutex = ::CreateMutex (NULL, True, "Global\\MyVeryOwnInstanceName");
if (hMutex)
{
if (::GetLastError () == ERROR_ALREADY_EXISTS)
{
::CloseHandle (hMutex);
throw "Only one instance allowed.";
}
else
::CloseHandle (hMutex);
}