To avoid conflicts with multiple services running in tandem, create
a lock mutex and prevent starting multiple instances.
Change-Id: I0b1eede3947d8baafa309ffd8e214029a4b79bc5
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
bool D3DService::start()
{
+ HANDLE runLock = CreateMutex(NULL, TRUE, L"Local\\qtd3dservice");
+ if (!runLock || GetLastError() == ERROR_ALREADY_EXISTS) {
+ qCWarning(lcD3DService) << "The service is already running.";
+ return false;
+ }
+
SetConsoleCtrlHandler(&control, TRUE);
// Create an invisible window for getting broadcast events
CloseHandle(waitHandles[i + 1]);
}
+ CloseHandle(runLock);
+
return true;
}