Block second instance
This commit is contained in:
1 parent
1a3932cae7
commit
6c7a975200
2 files changed
+19
No files matched your search
@@ -975,6 +975,23 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int)
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE instanceMutex = CreateMutexW(nullptr, FALSE,
|
||||
L"Local\\ParavisInstaller_SingleInstance");
|
||||
if (instanceMutex && GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
HWND existing = FindWindowW(kMainClass, nullptr);
|
||||
if (existing) {
|
||||
if (IsIconic(existing)) {
|
||||
ShowWindow(existing, SW_RESTORE);
|
||||
}
|
||||
SetForegroundWindow(existing);
|
||||
} else {
|
||||
MessageBoxW(nullptr, L"Paravis installer уже запущен.",
|
||||
L"Paravis installer", MB_ICONINFORMATION | MB_OK);
|
||||
}
|
||||
CloseHandle(instanceMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
INITCOMMONCONTROLSEX commonControls{};
|
||||
commonControls.dwSize = sizeof(commonControls);
|
||||
commonControls.dwICC = ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES;
|
||||
|
||||
Reference in new issue
Block a user