VS.NET在程序中关闭其他运行的程序

System.Diagnostics.Process myproc = new System.Diagnostics.Process();
        //得到所有打开的进程
        try
        {
            foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcessesByName(processName))
            {
                if (!thisproc.CloseMainWindow())
                {
                    if (thisproc != null)
                        thisproc.Kill();
                }
            }
        }

        catch (Exception Exc)
        {
            throw Exc;
        }

posted on 2010-08-27 13:48  和轩僮  阅读(317)  评论(0编辑  收藏  举报

导航