C#关闭进程的2种⽅法
private void KillProcess(string processName)
{苏子美
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
//得到所有打开的进程
try
{
foreach (Process thisproc in Process.GetProcessesByName(processName))
{
//到程序进程,kill之。安慰人的话语
if (!thisproc.CloseMainWindow())
人生感言适合发朋友圈{
thisproc.Kill();
}
}
黄伟文与杨千嬅}
catch (Exception Exc)
{
MessageBox.Show(Exc.Message);
}
}
public static void StopProcess(string processName)
{
try
{
System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName(processName);                foreach (System.Diagnostics.Process p in ps)
{
穆婷婷演过的电视剧p.Kill();
}
}
catch (Exception ex)
诺珉宇整容
{
throw ex;
}
}