在点开一次程序后,再去点开时,提示已运行程序。我加入了部分代码,但是提示完之后,仍然会弹出系统自带的警告。请问如何解决,我加入的代码如下: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什么的?

解决方案 »

  1.   

    CloseHandle(mMutex);
    你说的警告是什么?
      

  2.   

    Runtime Error!
    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
      

  3.   

    我改成下面这个样子了,主要是用了exit(0);请问这么写没有问题吧?
      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);

      } 
      

  4.   

    或者你也可以sendmessage(WM_CLOSE,0,0)
      

  5.   

    return FALSE;就可以了,InitInstance 放回FALSE,就会退出程序的。