C# 单例模式
在Program里写入代码:
static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new FnFather()); Mutex mutex = new Mutex(false, "SingelInstance"); if (!mutex.WaitOne(0, false)) { mutex.Close(); mutex = null; } if (mutex != null) { Application.Run(new FnFather()); } else { MessageBox.Show("程序已运行"); } } }