主要代码如下:
////////////////////////////////////////////////////////////
//结束进程函数
public bool endProcess(String strPro)
{
//创建进程数组,用于保存系统中所有的进程
Process[] p = Process.GetProcesses();
//循环判断进程组中是否有要结束的进程
foreach (Process pro in p)
{
String str = pro.ProcessName.ToString();
try
{
if (str == strPro)
{
//结束进程
pro.Kill();
return true;
}
}
catch {
return false;
}
}
return false;
}
///////////////////////////////////////////////////////////