Block second instance

This commit is contained in:
Paravis committed 2026-11-08 23:25:04 +03:00
1 parent b2ec20ddf9
commit 342690dfe9
2 files changed
+19

No files matched your search

+17
View File
@@ -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;