public static void CheckMutilApp() { var myProc = System.Diagnostics.Process.GetCurrentProcess(); var allProcs = System.Diagnostics.Process.GetProcesses(); int count = 0; foreach (var proc in allProcs) { try { if (myProc.ProcessName == proc.ProcessName) count++; } catch { } } if (count == 2) { throw new Exception("检测到程序重复打开!"); } if (count >= 2) { Environment.Exit(0); } }