- there can be only one instance of the device manager

svn path=/trunk/; revision=28905
This commit is contained in:
Johannes Anderwald 2007-09-06 19:45:26 +00:00
parent ac5a5581cd
commit 58f165a052

View file

@ -11,6 +11,7 @@
HINSTANCE hInstance; HINSTANCE hInstance;
HANDLE ProcessHeap; HANDLE ProcessHeap;
HANDLE hMutex;
int WINAPI int WINAPI
_tWinMain(HINSTANCE hThisInstance, _tWinMain(HINSTANCE hThisInstance,
@ -24,6 +25,18 @@ _tWinMain(HINSTANCE hThisInstance,
int Ret = 1; int Ret = 1;
INITCOMMONCONTROLSEX icex; INITCOMMONCONTROLSEX icex;
hMutex = CreateMutex(NULL, TRUE, _T("devmgmt_mutex"));
if (hMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
if (hMutex)
{
CloseHandle(hMutex);
}
return 0;
}
hInstance = hThisInstance; hInstance = hThisInstance;
ProcessHeap = GetProcessHeap(); ProcessHeap = GetProcessHeap();
@ -59,7 +72,7 @@ _tWinMain(HINSTANCE hThisInstance,
} }
LocalFree((HLOCAL)lpAppName); LocalFree((HLOCAL)lpAppName);
CloseHandle(hMutex);
return Ret; return Ret;
} }