Execute Once

This is a discussion on Execute Once within the Windows Programming forums, part of the Platform Specific Boards category; How some programs can be executed any times you want but some can't? For example each time you open internet ...

  1. #1
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236

    Question Execute Once

    How some programs can be executed any times you want but some can't? For example each time you open internet explorer, it opens a new process. But some programs don't behave this like, for example Midtown Madness or Yahoo messenger. They can only be executed once.
    I want to write a program in this way.
    There is also (maybe) more advanced mechanism, when opening Office Word, more than once, it is like pressing New in File menu.
    One way to do so is to write something somewhere (in a file or win reg) and set it at first execution, then from that time on, program can check that to see it should be executed or not. But I think this technique is not safe, because anybody can change that value to fool the program. It needs an OS function to prevent this. For example when foo.exe executed for the first time, it will tell OS not to execute a process with this name again (or something like that). Now it needs an advanced hacker to fool the program. Is there any function in Win32 API?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    When the program starts it should check to see if there is another instance of itself already running. On a quick search I found this site: http://www.clearnight.com.au/cnspi.htm
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Three solutions on this board in one thread....

    How do you only allow one instance of an app?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    Thanks, I got the idea.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Execute Command from C fcn in DLL
    By karcheee in forum Windows Programming
    Replies: 2
    Last Post: 07-27-2005, 04:42 PM
  2. Execute prog as other user
    By groorj in forum C Programming
    Replies: 2
    Last Post: 05-04-2005, 01:28 PM
  3. classes won't execute
    By Mr.Pink in forum C++ Programming
    Replies: 4
    Last Post: 02-20-2005, 11:47 AM
  4. Execute from another program using C#
    By Grayson_Peddie in forum C# Programming
    Replies: 4
    Last Post: 05-04-2003, 01:03 PM
  5. Replies: 4
    Last Post: 01-22-2003, 03:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21