运行一个程序实例,只显示了一个对话框界面,什么都没做.
再运行一次同样的程序,为了只运行一个实例,做了如下:
HANDLE hSem =CreateMutex(NULL,TRUE, m_pszAppName);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hSem);
AfxMessageBox("本程序现在正在运行!");
return FALSE;
}放在InitInstance()的最前面.只运行一次程序退出时,不会有任何问题.运行第二个程序时,会出错:
Debug Error
abnormal progrqam terminationruntime error
abnormal progrqam termination
再运行一次同样的程序,为了只运行一个实例,做了如下:
HANDLE hSem =CreateMutex(NULL,TRUE, m_pszAppName);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hSem);
AfxMessageBox("本程序现在正在运行!");
return FALSE;
}放在InitInstance()的最前面.只运行一次程序退出时,不会有任何问题.运行第二个程序时,会出错:
Debug Error
abnormal progrqam terminationruntime error
abnormal progrqam termination
1楼的也照做了,还是一样的.
m_hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, strClassName);
if (m_hMutex == NULL)
{
m_hMutex = ::CreateMutex(NULL, TRUE, strClassName);
}
else
{
::AfxMessageBox(_T("程序已运行!"));
return FALSE;
}在ExitInstance中:
if (m_hMutex != NULL) //关闭互斥量
{
::ReleaseMutex(m_hMutex);
}
if (m_hMutex != NULL) //关闭互斥量
{
::ReleaseMutex(m_hMutex);
}
Unhandled exception in **.exe (KERNEL32.DLL):)xE06D7363:Microsoft C++ Exception光标停在这一行
7C812AF8 pop esiesi的值为1244636这要如何检查?