Hello all, I need to ensure that the program I've created has only one running instance on a given machine. This is the solution that I decided on (pattern found at http://www.ai.uga.edu/~mc/SingleInstance.html):
[STAThread] public static void Main() { bool ok; Mutex m = new Mutex(true, "ProgID", out ok); // make sure only one instance of program is running if (! ok) { MessageBox.Show("Already running.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.Run(new MainForm()); GC.KeepAlive(m); // don't let the GC eat our mutex } ** end The problem is that this only prevents the process from running more than once in a user session. The program runs on a server (it really should be a Windows service, but can't be due to ridiculous requirements beyond my control), so if it's running on the console session, someone is still able to use terminal services, log in, and run another instance. Therefore, I need some sort of "system global" mutex, or another mechanism to achieve this. What's the best way? Thanks! -- Neils Christoffersen =================================== This list is hosted by DevelopMentorŪ http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com