WinForm 只允许打开一个程序

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Dachie
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool createNew;

            System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew);
            if (createNew)
                Application.Run(new login());
        }
    }
}
原文地址:https://www.cnblogs.com/dachie/p/1734434.html