C#中用kill杀不死进程?
今天跟着书学习写了一个显示系统当前进程的程序,在程序中有用kill命令杀死进程,为什么当我选择杀死explorer进程时,计算机没有反应呢?
private void button2_Click(object sender, EventArgs e) { //首先判断是否已经选择某个进程 if (listView1.SelectedItems.Count >= 1) { // 根据进程的ID查找该进程 Process p = Process.GetProcessById(Convert.ToInt32(listView1.SelectedItems[0].SubItems[1].Text)); // 为了防止用户误操作,提示用户 if (MessageBox.Show("确定要结束进程吗?", "结束进程", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { if (p != null) p.Kill(); } } }
Process p = new Process.getProcessbyName("name"); p.kill();
[解决办法]
IntPtr t = new IntPtr(name.Hwnd);
int k = 0; GetWindowThreadProcessId(t, out k);
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(k);
p.Kill();
[解决办法]
http://blog.csdn.net/neusoft06/article/details/7553387
参考一下
[解决办法]
GetCurrentProcessById().Kill()
[解决办法]