可能重复:
What is the correct way to create a single instance application?
如何将我的应用程序定义为在反复点击其exe文件后只打开一次?
答案 0 :(得分:3)
有关Single Instance Applications的堆叠溢出的几个相关问题:
这个似乎是最合适的:What is the correct way to create a single-instance application?
答案 1 :(得分:0)
我总是在应用程序的入口点完成此操作:
bool onlyInstance = false;
Mutex m = new Mutex(true, "MyUniqueMutextName", out onlyInstance);
if (!onlyInstance)
{
return;
}
GC.KeepAlive(m);