Thread: Check if program is alreadi running

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005

    Check if program is alreadi running

    Whats the function i should look for if i wan to check if a similar program is alreadi running ?
    ETC: i run program A, and i click A.exe again, i wan program A to auto restore instead of running another A again.
    /* Have a nice day */

  2. #2
    Registered User
    Join Date
    Apr 2002
    You can do it pretty easily with a Mutex. Something like this should do the trick:

      if(CreateMutex(NULL, FALSE, pClassName) && (GetLastError() == ERROR_ALREADY_EXISTS)) 
    	SetForegroundWindow(FindWindow(pClassName, NULL));
    	// ExitProcess or whatever
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory not released after running program
    By lehe in forum Linux Programming
    Replies: 21
    Last Post: 01-01-2011, 03:32 AM
  2. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  3. FAQ : running program inside program (spawn)
    By nipun in forum C Programming
    Replies: 3
    Last Post: 06-13-2004, 02:30 PM
  4. Running another program in windows
    By Mr_Jack in forum C++ Programming
    Replies: 4
    Last Post: 01-22-2004, 02:01 AM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 10:57 AM