CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Posts
    331

    Prevent another instance of application from running

    Hi,

    How can I prevent another instance of my MFC application from running? I'm using Visual Studio 2005. Thank you.

  2. #2
    Join Date
    Dec 2008
    Posts
    144

    Re: Prevent another instance of application from running


  3. #3
    Join Date
    Feb 2005
    Posts
    331

    Re: Prevent another instance of application from running

    Thanks! I used the information here instead.
    Last edited by galapogos; January 20th, 2010 at 03:52 AM.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,397

    Re: Prevent another instance of application from running

    Quote Originally Posted by galapogos View Post
    Thanks! I used the information here instead.
    Well, there is a "full version" of how to solve the problem: Avoiding Multiple Application Instances
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Prevent another instance of application from running

    The 'instance count' in a shared data segment, while valid if implemented correctly (which it isn't here as the 'lock' and 'lock check' are independant and thus could result in a failure), is a less than ideal solution for various reasons, a shared data segment for one may not give you the desired operation when running on a terminal server or when using fast user switching.

    Using a mutex (either global or local) remains to be simple and more guaranteed to work properly under all conditions.

    At least none seem to be suggesting the window approach. that's just really major fail trying to solve it that way :-p

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