CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Location
    Miami, FL
    Posts
    15

    detect if already running

    Hi,
    I want to make my app, when i run it, if an instance is already running, to close that instance and run the app again.
    What is the best solution:
    to kill the process then start the program
    or is there any way to do it ?
    thanks

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: detect if already running

    You need to setup a protocol for these 2 processes to communicate.
    I have found this an exhaustive essay on the approaches you can use:
    http://www.flounder.com/nomultiples.htm

    One of the technique involves in sending a registered message by the later invoked applicaiton to the previously invoked app and interpreting this message on both sides to do the necessary. You can customize this behavior to adapt to your needs.

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: detect if already running

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Dec 2007
    Location
    Vancouver
    Posts
    25

    Re: detect if already running

    Hi,

    You can call CreateMutex to create a global mutex.
    When you run it, try to open the mutex and check it's state, if it has been created, exits your app directly.

    Thanks.
    Catherine Sea
    www.dynamsoft.com
    the the leading developer of version control and issue tracking software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured