   Preventing multiple instances of the program from being open?
  Hey all.  The topic pretty much says what I want to do.  One and only one game being open at a time.I'm using Visual C++ 2008 and this game is for Windows.  Any easy way to go about doing it?Thanks!   
  The traditional solution is to use CreateMutex() to create a named mutex at the beginning of your application with bInitialOwner set to true. If, after CreateMutex() call, GetLastError() returns ERROR_ALREADY_EXISTS, then an existing instance of your application is running and your program should exit.   ;  I relish the irony of the text in this link... ERROR_ALREADY_EXISTS;BOOL DoIExist( LPCTSTR szMutexName ){    // Create Mutex. Fails if already existsHANDLEg_hMutexAppIsRunning;g_hMutexAppIsRunning = CreateMutex( NULL, FALSE, szMutexName );    // Return TRUE if existing semaphore opened  if (g_hMutexAppIsRunning != NULL && GetLastError()==ERROR_ALREADY_EXISTS)    {    CloseHandle(g_hMutexAppIsRunning);   return TRUE;   };    // Was not Found. New one Created, return falsereturn (g_hMutexAppIsRunning==NULL);};Perhaps not the best way to do it, so use it with a grain of salt. It does work for me though.   ;  Prozak: Shouldn't that mutex also be released somewhere? Or do you let Windows auto-cleanup it?   ;Quote:Original post by EndurionProzak: Shouldn't that mutex also be released somewhere? Or do you let Windows auto-cleanup it?Well, you should clean it up on exit, but I'm quite sure Windows does a good job on cleanup too.   