using System.Diagnostics; namespace Check.Main { internal static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { var current = Process.GetCurrentProcess(); var others = Process.GetProcessesByName(current.ProcessName) .Where(p => p.Id != current.Id); if (others.Any()) { MessageBox.Show("程序已经在运行中,不能重复启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); Application.Run(new FrmMain()); } } }