'중복실행'에 해당되는 글 1건

  1. 2008.09.05 MFC 중복실행 방지 - Mutex
Programming/MFC2008. 9. 5. 01:19

BOOL CEasyInterfaceApp::InitInstance()
{
 HANDLE hMutex = CreateMutex(NULL, TRUE, "EasyInterFace");
 
 if(GetLastError() == ERROR_ALREADY_EXISTS)
 {
  ReleaseMutex(hMutex);
 
  CWnd *pWndPrev, *pWndChild;
 
  if(pWndPrev = CWnd::FindWindow(NULL, "EasyInterFace"))
  {
   pWndChild = pWndPrev->GetLastActivePopup();
   
   if(pWndPrev->IsIconic())
    pWndPrev->ShowWindow(SW_RESTORE);
   
   pWndChild->SetForegroundWindow();
  }
 
  return FALSE;
 }
 ReleaseMutex(hMutex);
}
Posted by skensita