编译工具:Microsoft Visual Studio 2005
使用语言:C#
程序用途:检索当前Windows运行的进程,并可以执行关闭.
详细源码:
代码
using System;
namespace st_Face_GoRush
{
class Program
{
public static void Main(string[] args)
{
//开始。
System.Int16 i;
System.String StrNameID;
System.Diagnostics.Process[] ShowID = System.Diagnostics.Process.GetProcesses();
for (i = 0; i < ShowID.Length; i++)
System.Console.WriteLine(ShowID[i].ProcessName + " " + ShowID[i].Id);
System.Threading.Thread.Sleep(200);
System.Console.Write("请输入你要关闭的进程名称: ");
StrNameID = System.Convert.ToString(System.Console.ReadLine());
System.Diagnostics.Process[] CloseID = System.Diagnostics.Process.GetProcessesByName(StrNameID);
//
if (CloseID.Length != 0)
{
for (i = 0; i < CloseID.Length; i++)
{
if (CloseID[i].Responding && !CloseID[i].HasExited)
{
System.Console.WriteLine("指定进程存在而且正在响应中...正在关闭.");
CloseID[i].CloseMainWindow();
if (!CloseID[i].HasExited)
{
System.Console.WriteLine("由于特别原因无法关闭进程,现在强制关闭!!!");
CloseID[i].Kill();
}
}
else
{
System.Console.WriteLine("指定进程存在但无法响应...正在强制关闭!");
CloseID[i].Kill();
}
}
}
else
System.Console.WriteLine("指定进程不存在无法关闭!请确认输入正确.");
}
}
}