Last active
August 29, 2015 13:59
-
-
Save polovik/10714312 to your computer and use it in GitHub Desktop.
Verify unique instance of application in WinApi (Visual Studio C++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) | |
{ | |
// Avoid multiple instances of application | |
const WCHAR *applicationMutexName = L"autorun_st"; | |
HANDLE mutexAppHandle = CreateMutex(NULL, TRUE, applicationMutexName); | |
if (GetLastError() == ERROR_ALREADY_EXISTS) { | |
CloseHandle(mutexAppHandle); | |
return EXIT_FAILURE; | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment