Subj : Create Only One Instantance of the Same Application To : borland.public.cpp.borlandcpp From : akuma Date : Wed Dec 29 2004 05:20 pm Hi, I have problem on avoiding the same application running many times by the CreateEvent / CreateMutex API function after my system was upgraded to Windows XP SP2 from SP1. I tried the following example: // BOOL IsAppRunning (LPCTSTR szAppString) { TCHAR szEventName[MAX_PATH]; HANDLE g_hAppRunningEvent = INVALID_HANDLE_VALUE; lstrcpy (szEventName, TEXT("Global\\SingleInstApp_")); lstrcat (szEventName, szAppString); g_hAppRunningEvent = CreateEvent (NULL, FALSE, FALSE, szEventName); if (g_hAppRunningEvent != NULL) { // See if the event already exists. if (GetLastError() == ERROR_ALREADY_EXISTS) { // The app is already running CloseHandle(g_hAppRunningEvent); g_hAppRunningEvent = NULL; } } //g_hAppRunningEvent is destroyed when the app terminate return (g_hAppRunningEvent == NULL); } // This works only on Windows XP SP1 or before. It does nothing on Windows XP SP2. Please help me, thanks! .