控制仅打开单实例进程
/// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { //控制仅打开单实例进程 if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length == 1) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { MessageBox.Show("该程序已经运行!"); } }