=== 실행 시 === {{{#!gcode BOOL CheckValidApp() { DWORD dwError; SECURITY_DESCRIPTOR sd = {0,}; InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE); SECURITY_ATTRIBUTES sa = {0,}; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = &sd ; m_hMutex = ::CreateMutex(&sa, TRUE, _T("name_of_my_mutex")); dwError = ::GetLastError(); if (m_hMutex == NULL) return FALSE; if (dwError == ERROR_ALREADY_EXISTS) { DWORD dwWaitResult = 0; dwWaitResult = WaitForSingleObject(m_hMutex, 3000); switch(dwWaitResult) { case WAIT_TIMEOUT: ::ReleaseMutex(m_hMutex); ::CloseHandle(m_hMutex); return FALSE; case WAIT_OBJECT_0: return TRUE; case WAIT_ABANDONED: return TRUE; default: break; } return FALSE; } return TRUE; } }}} === 종료 시 === OnDestroy 등에서 뮤텍스 제거