Results 1 to 2 of 2

Thread: Preventing Multiple Instance

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question Preventing Multiple Instance

    I need to prevent the user from opening multiple instance of an application? If an instance is already running and if the user clicks on the exe icon i need to shift focus on the application which was opened?

    Am able to display a MessageBox if there is already an instance running like:
    Code:
    if(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).GetUpperBound(0)>=1)
    {
    MessageBox.Show("An Instance of the application is already open.","Press Inventory Management",MessageBoxButtons.OK,MessageBoxIcon.Information);  
    this.Close(); 
    }
    Help me out?

  2. #2

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310
    I got the answer:
    http://www.codeproject.com/csharp/oneProcessOnly.asp

    but this uses: System.Runtime.InteropServices

    Is there anyway of doing it without System.Runtime.InteropServices as this will not be as efficent as an inbuilt .NET class something like System.Application...or Ssytem.Applications..where one can enumerate all the Applications running?

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