判断进程状态
根据进程名称判断进程是否启动:
//根据名称获取进程pid public static int GetPidByProcessName(string processName) { Process[] arrayProcess = Process.GetProcessesByName(processName); foreach (Process p in arrayProcess) { return p.Id; } return 0; } //判断进程状态 public void judgeprocessisrunning(string name) { if (GetPidByProcessName(name) == 0) { MessageBox.Show("指定程序未运行"); } else MessageBox.Show("正在运行中"); }