windows mobile进程查看器开发(二)—— 停止进程

在上一篇的Process类中添加:

 

public void Kill() { IntPtr hProcess; hProcess = OpenProcess(PROCESS_TERMINATE, false, (int)processId); if (hProcess != (IntPtr)INVALID_HANDLE_VALUE) { bool bRet; bRet = TerminateProcess(hProcess, 0); CloseHandle(hProcess); } [DllImport("coredll.dll")] private static extern IntPtr OpenProcess(int flags, bool fInherit, int PID); private const int PROCESS_TERMINATE = 1; [DllImport("coredll.dll")] private static extern bool TerminateProcess(IntPtr hProcess, uint ExitCode); [DllImport("coredll.dll")] private static extern bool CloseHandle(IntPtr handle); private const int INVALID_HANDLE_VALUE = -1; }

 

 

你可能感兴趣的:(windows mobile进程查看器开发(二)—— 停止进程)