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.
Printable View
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.
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);
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);