A agro_r Apr 15, 2004 #1 I don't want more than one instance of my program running in a particular user. How can I do that in .NET? Thanks a lot...
I don't want more than one instance of my program running in a particular user. How can I do that in .NET? Thanks a lot...
K Klaus H. Probst Apr 15, 2004 #2 using System.Diagnostics; Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName) If the returned array length is not zero then you have a previous instance.
using System.Diagnostics; Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName) If the returned array length is not zero then you have a previous instance.
J Jon Skeet [C# MVP] Apr 15, 2004 #3 Klaus H. Probst said: using System.Diagnostics; Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName) If the returned array length is not zero then you have a previous instance. Click to expand... Or another process which happens to have the same name. Personally I prefer the mutex approach, as you realistically can have a longer name which is more likely to be unique. See http://www.pobox.com/~skeet/csharp/faq/#one.application.instance
Klaus H. Probst said: using System.Diagnostics; Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName) If the returned array length is not zero then you have a previous instance. Click to expand... Or another process which happens to have the same name. Personally I prefer the mutex approach, as you realistically can have a longer name which is more likely to be unique. See http://www.pobox.com/~skeet/csharp/faq/#one.application.instance