C#得到系统进程和结束某个指定的进程

2010-08-28 10:50:01来源:西部e网作者:

获得当前计算机系统内所有的已启动的进程:

System.Diagnostics.Process[] processOnComputer = System.Diagnostics.Process.GetProcesses();
foreach ( System.Diagnostics.Process p in processOnComputer )
{
System.Console.WriteLine(p.ToString());
}
Console.ReadLine();

获得当前计算机系统内某个进程并关闭:

System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName("进程名称");
foreach ( System.Diagnostics.Process p in process)
{
p.Kill();
}

关键词:C#