版权声明:博主原创/资料整理,转载请注明出处!! https://blog.csdn.net/tiegenZ/article/details/82781336
禁止程序二次启动我使用是如下代码:(通过判断程序是否启动来禁止二次启动)
static void Main()
{
bool createNew;
// 只能运行一次程序
using (Mutex m = new Mutex(true, Application.ProductName, out createNew))
{
if (createNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("程序已经运行");
}
}
}