防止应用程序重复启动可在应用程序类的InitInstance函数中加入如下代码:
HANDLE hMutex=::CreateMutex(NULL,TRUE,m_pszAppName); if (GetLastError()==ERROR_ALREADY_EXISTS) { MessageBox(NULL,"程序已经启动了!","提示",MB_ICONINFORMATION); CloseHandle(hMutex); return FALSE; }