So if you put that code in the OnLoad() override of the main Form the first instance will close. If you change the test to be greater than 1 it will work. However if a user copies the .exe file to a different name then they can create an instance for each copy of the file they create.
Using a Mutex eliminates both of those limitations.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.