【C#】限制应用程序打开一次
static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Process[] proc = Process.GetProcesses(); int cnt = 0; for (int i = 0; i < proc.Length; i++) { if (proc[i].ProcessName != null && proc[i].ProcessName == "xxx") { cnt++; } if (cnt > 1) { MessageBox.Show("重复启动" + proc[i].ProcessName); Application.Exit(); return; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } }
/*******相与枕藉乎舟中,不知东方之既白*******/

浙公网安备 33010602011771号