asp.net 获取进程。。杀到进程
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Diagnostics;
using System.Collections;

public partial class user_Exposure : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //得到所有打开的进程
        ArrayList procList = new ArrayList();
        string tempName = "";
        int begpos;
        int endpos;
        foreach (Process thisProc in Process.GetProcesses())
        {
            tempName = thisProc.ToString();
            begpos = tempName.IndexOf("(") + 1;
            endpos = tempName.IndexOf(")");
            tempName = tempName.Substring(begpos, endpos - begpos);
            procList.Add(tempName);
        }
        DropDownListProcname.DataSource = procList;
        DropDownListProcname.DataBind();
       
    }
    private void KillProcess(string processName)
    {
        //得到所有打开的进程
        try
        {
            foreach (Process thisProc in Process.GetProcessesByName(processName))
            {
                if (!thisProc.CloseMainWindow())
                {  Button2.Text = thisProc.MainModule.FileName;
                    thisProc.Kill();
                  
                }
            }
        }
        catch
        {
          
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {


        KillProcess(DropDownListProcname.SelectedItem.Text);
     
        
       
    }
}
阅读更多
个人分类: ASP.NET 王小贩 aspx
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

asp.net 获取进程。。杀到进程

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭