分类: C/C++
2010-10-22 19:11:48
1.要点
2.实现代码
1: //At the entry point, such aa the beginning of WinMain in Win32 app,
2: //or CWinApp::InitInstance() in MFC app
3: LPCTSTR instanceName =4: _T("AD83912A-43F2-4BF6-B0CF-02BF6589FFF7"); //Generated with GuidGen tool5: HANDLE h = ::CreateMutex(NULL,FALSE,instanceName);6: DWORD error = GetLastError();7: if (error == ERROR_ALREADY_EXISTS)
8: {9: ::CloseHandle(h);10: return FALSE; //Exist11: }12:13: //.......
14:15: //At the exist point, close the named object and then exist
16: ::CloseHandle(h);17: return FALSE; //Exist18: