Winform 程序禁止重复打开, 只能运行一个程序, 禁止多开

Winform 程序禁止重复打开, 只能运行一个程序, 禁止多开
using System;
using System.Windows.Forms;
using System.Threading;
 
namespace Test
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool result;
            Application.EnableVisualStyles();
            Mutex m = new Mutex(true, Application.ProductName, out result);
            if (result)
            {
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainFrom());
            }
        }
    }
}


热门推荐