CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Springfield
    Posts
    190

    I want one application instance only

    How can I prevent from opening more than one instance of my application? e.g. I want that when the user clicks on the exe file for the 2nd time then the program quits immediately.
    Mr. Burns

  2. #2
    Join Date
    Nov 2002
    Location
    Columbus, Ohio
    Posts
    117
    in the main(), do a wrap on the Application.Run(new yourapp);


    Process[] p = Process.GetProcessByName("youApp");
    if (p.Length == 1) Application.Run(new yourapp);
    Its better to have people think you're a fool than to open your mouth and remove all doubt.

  3. #3
    Join Date
    Jul 2003
    Location
    Springfield
    Posts
    190
    Thank you very much! I could replace that Homer Simpson with you in my factory!
    But mind the spelling:
    Code:
    Process[] p = Process.GetProcessesByName("youApp");
    if (p.Length == 1)
      Application.Run(new yourapp);
    Mr. Burns

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