using System.Diagnostics; using System.Windows.Forms; namespace Xarp { class run_one { public static bool is_not_runed() { Process current_p = Process.GetCurrentProcess(); Process[] ps = Process.GetProcesses(); foreach (var p in ps) { if (p.ProcessName == current_p.ProcessName && p.Id != current_p.Id) { MessageBox.Show("已经有一个程序在运行中!"); return false; } } return true; } } } |
|