using System.Threading;
using System.Windows.Forms;
[STAThread]
static void Main(string[] args)
{
bool ret;
Mutex mutex = new Mutex(true, Application.ProductName, out ret);
if(ret)
{
Application.Run(new MainWnd());
m.RealseMutex();
}
else
{
// 已启动
}
}
使用Mutex防止应用程序多次运行
本文介绍了一种使用Mutex来防止Windows应用程序被多次运行的方法。通过创建一个互斥对象Mutex并检查其返回值,可以确保应用程序在同一时间内仅运行一个实例。

被折叠的 条评论
为什么被折叠?



