C# 禁止程序重复启动

修改:Program.cs

[STAThread]
static void Main()
{
    Mutex mutex = new Mutex(true, "NewGuid123456", out bool isCreatedNew);
    if (!isCreatedNew)
    {
        MessageBox.Show(Application.ProductName + "is running...");
        return;
    }

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

参考:C# 禁止程序重复启动

你可能感兴趣的:(c#)