在应用程序的InitInstance方法中,添加如下几行代码:
CreateMutex(NULL,true,m_pszAppName);if(GetLastError() == ERROR_ALREADY_EXISTS){ AfxMessageBox(_T("程序已启动"),MB_OK | MB_APPLMODAL | MB_ICONSTOP); return false;}
本文共 236 字,大约阅读时间需要 1 分钟。
在应用程序的InitInstance方法中,添加如下几行代码:
CreateMutex(NULL,true,m_pszAppName);if(GetLastError() == ERROR_ALREADY_EXISTS){ AfxMessageBox(_T("程序已启动"),MB_OK | MB_APPLMODAL | MB_ICONSTOP); return false;}
转载于:https://blog.51cto.com/shenyantao/1547363