mfc程序小结
1.单例进程
在CxxApp类的InitInstance()开头添加代码
//利用互斥实现单例进程模式
HANDLE hMutex = ::CreateMutex(NULL, TRUE, _T("appIdentification"));
if (hMutex != NULL)
{
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
MessageBox(NULL, _T("程序已经运行"), _T("提示"), 0);
CloseHandle(hMutex);
return FALSE;
}
}