mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Implemented single-instance checking.
This commit is contained in:
+23
-2
@@ -50,8 +50,8 @@ using boost::format;
|
||||
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
|
||||
|
||||
// First do application loading.
|
||||
//------------------------------
|
||||
// Do application init
|
||||
//--------------------
|
||||
|
||||
string initError;
|
||||
YAML::Node settings;
|
||||
@@ -148,6 +148,23 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
|
||||
// Check if LOOT is already running
|
||||
//---------------------------------
|
||||
|
||||
HANDLE hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, L"LOOT.Shell.Instance");
|
||||
if (hMutex != NULL) {
|
||||
// An instance of LOOT is already running, so quit.
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
//Create the mutex so that future instances will not run.
|
||||
hMutex = ::CreateMutex(NULL, FALSE, L"LOOT.Shell.Instance");
|
||||
}
|
||||
|
||||
// Back to CEF
|
||||
//------------
|
||||
|
||||
// Initialise CEF settings.
|
||||
CefSettings cef_settings;
|
||||
|
||||
@@ -169,5 +186,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd
|
||||
// Shut down CEF.
|
||||
CefShutdown();
|
||||
|
||||
// Release the program instance mutex.
|
||||
if (hMutex != NULL)
|
||||
ReleaseMutex(hMutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user