--System.Diagnostics.Process 提供对本地和远程进程的访问并使您能够启动和停止本地系统进程。
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process myProcess in myProcesses)
{
if (myProcess.ProcessName.ToUpper() == ProcessesName)
{
myProcess.Kill();
break;
}
}
或则
System.Diagnostics.Process[] sProcesses = System.Diagnostics.Process.GetProcesses();
for (int i = 0; i < sProcesses.Length; i++)
{
if (sProcesses[i].ProcessName.ToLower().Trim() == ProcessesName)//ToLower()全部小写
{
sProcesses[i].Kill();
break;
}
}