- //在互斥体的前面加上全局"Global\\",可以使多个session下只运行一个实例
- HANDLE hMutex = CreateMutex(NULL, FALSE, _T("Global\\SysCheck"));
- if (hMutex!=NULL && GetLastError() == ERROR_ALREADY_EXISTS)
- {
- ReleaseMutex(hMutex);
- hMutex = NULL;
- cout<<"已有实例在运行!"<<endl;
- return FALSE;
- }