在点开一次程序后,再去点开时,提示已运行程序。我加入了部分代码,但是提示完之后,仍然会弹出系统自带的警告。请问如何解决,我加入的代码如下:BOOL CYuhtApp::InitInstance()
{
AfxEnableControlContainer(); HANDLE mMutex = CreateMutex(NULL, FALSE, "ECGBASE Mutex");
if (mMutex == NULL)
{ AfxMessageBox("Initialize failed!");
return FALSE;
}
else
if (GetLastError() == ERROR_ALREADY_EXISTS)
{ AfxMessageBox("The program already exist!");
return FALSE;
}
附带问一下,这里的 HANDLE mMutex用完之后是不是需要delete什么的?
{
AfxEnableControlContainer(); HANDLE mMutex = CreateMutex(NULL, FALSE, "ECGBASE Mutex");
if (mMutex == NULL)
{ AfxMessageBox("Initialize failed!");
return FALSE;
}
else
if (GetLastError() == ERROR_ALREADY_EXISTS)
{ AfxMessageBox("The program already exist!");
return FALSE;
}
附带问一下,这里的 HANDLE mMutex用完之后是不是需要delete什么的?
你说的警告是什么?
Program:...ator/E:/Test/Debug/Test.exe
This program has requested the Runtime to terminated it in an unusual way.Please contact the application's support team for more information
HANDLE mMutex = CreateMutex(NULL, FALSE, "ECGBASE Mutex");
if (mMutex == NULL)
{
// Failure
AfxMessageBox("Initialize failed!");
return FALSE;
}
else if (GetLastError() == ERROR_ALREADY_EXISTS)
{
AfxMessageBox("The program already exist!");
CloseHandle(mMutex);
exit(0);
}