标签:close 代码 code already mutex exists cat last sage
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;
}
}
标签:close 代码 code already mutex exists cat last sage
原文地址:https://www.cnblogs.com/bhoold/p/12159093.html