防止应用程序重复启动可在应用程序类的InitInstance函数中加入如下代码:
HANDLE hMutex=::CreateMutex(NULL,TRUE,m_pszAppName);
if (GetLastError()==ERROR_ALREADY_EXISTS)
{
MessageBox(NULL,"程序已经启动了!","提示",MB_ICONINFORMATION);
CloseHandle(hMutex);
return FALSE;
}
防止应用程序重复启动可在应用程序类的InitInstance函数中加入如下代码:
HANDLE hMutex=::CreateMutex(NULL,TRUE,m_pszAppName);
if (GetLastError()==ERROR_ALREADY_EXISTS)
{
MessageBox(NULL,"程序已经启动了!","提示",MB_ICONINFORMATION);
CloseHandle(hMutex);
return FALSE;
}
转载于:https://www.cnblogs.com/shinecox/archive/2013/04/23/3038757.html