进程寻找与终止
//寻找进程 public bool ExProgress(string name) { bool init = false; try { Process[] prc = Process.GetProcesses(); foreach (Process pr in prc) //遍历整个进程 { if (name == pr.ProcessName) //如果进程存在 { //LogHelp.WriteInLog("接口已经存在:" + pr.ProcessName.ToString(), true); return true; } else { init = false; } } return init; } catch (Exception) { return false; } } public bool KillProgress(string name) { bool init = false; try { Process[] prc = Process.GetProcesses(); foreach (Process pr in prc) //遍历整个进程 { if (name == pr.ProcessName) //如果进程存在 { pr.Kill(); return true; } else { init = false; } } return init; } catch (Exception) { return false; } }