CE上面和PC上终止进程方法少了很多,许多PC上的方法根本不能适用于CE。 看了好多博客都是读出进程列表,然后跟要结束的进程去递归查找。
这里有一个ProcessCE.cs文件可以结束指定的进程。
要列举正在运行的进程:
ProcessInfo[] list = ProcessCE.GetProcesses();
foreach (ProcessInfo item in list)
{
Debug.WriteLine("Process item: " + item.FullPath);
if (item.FullPath == @"\Windows\iexplore.exe")
item.Kill();
}
要检查某个进程是否正在运行:
bool result = ProcessCE.IsRunning(@"\Windows\iexplore.exe");
为了找到一个进程ID(PID):
IntPtr pid = ProcessCE.FindProcessPID(@"\Windows\iexplore.exe");
if (pid == IntPtr.Zero)
throw new Exception("Process not found.");
要终止一个进程:
bool result = ProcessCE.FindAndKill(@"\Windows\iexplore.exe");
ProcessCE文件下载