Block second instance
This commit is contained in:
1 parent
b2ec20ddf9
commit
342690dfe9
2 files changed
+19
No files matched your search
@@ -375,6 +375,23 @@ void App::OnPoll()
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int)
|
||||
{
|
||||
HANDLE instanceMutex = CreateMutexW(nullptr, FALSE,
|
||||
L"Local\\ChangeBootLoader_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"Change BootLoader уже запущен.",
|
||||
kWindowTitle, MB_ICONINFORMATION | MB_OK);
|
||||
}
|
||||
CloseHandle(instanceMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
App app;
|
||||
app.hInst = hInstance;
|
||||
|
||||
|
||||
Reference in new issue
Block a user