There can be only one....
This is an old trick, but updated for the .NET world.
Question, how do you keep more than one instance of an app from running (this can be especially useful for Terminal Server scenarios).
Mutex m; public Form1() { InitializeComponent(); bool gotIt = false; m = new Mutex(true, "SomethingReallyUnique", out gotIt); if (!gotIt) { MessageBox.Show("This application is already running."); Application.Exit(); } }
[Sean 'Early' Campbell & Scott 'Adopter' Swigart's Radio Weblog]
11:58:10 AM
|