How to prevent open my application more than one time?

Possible Duplicate:
What is the correct way to create a single instance application?

How can I define my application to open only one time after click on its exe file over and over?


我一直在应用程序的入口处完成此操作:

bool onlyInstance = false;

Mutex m = new Mutex(true, "MyUniqueMutextName", out onlyInstance);
if (!onlyInstance)
{
    return;
}

GC.KeepAlive(m);

There are several related questions on Stack Overflow for Single Instance Applications:

This one seems to be the most apropriate: What is the correct way to create a single-instance application?

链接地址: http://www.djcxy.com/p/51148.html

上一篇: C#中的单例问题

下一篇: 如何防止多次打开我的应用程序?