C# kill 进程

 private void button1_Click(object sender, EventArgs e)
        {
        
            Process[] allProcess = Process.GetProcesses();
            foreach (Process p in allProcess)
            {
                string processName = "WinConst.vshost";
                // 判断主程序是否在运行
                if (processName.ToLower().Trim() == p.ProcessName.ToLower().Trim())
                {

                    for (int i = 0; i < p.Threads.Count; i++)
                        p.Threads[i].Dispose();
                    p.Kill();

                    break;
                }
            }

       
        }

posted @ 2013-05-07 20:44  Predator  阅读(619)  评论(0编辑  收藏  举报