在C#中怎么终止一个进程。 http://dotnet.aspx.cc/ShowDetail.aspx?id=299D1529-59A3-42F9-77A7-7BF353754FEA 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个里面有关闭IE进程的代码,可能能用的上:http://www.c-sharpcorner.com/Code/2002/Mar/CaptRunIEInstances.asp 以下是C#代码:<%@ Page Language="c#" %><HTML><HEAD><% @ Import namespace= "System.Diagnostics" %><script language="C#" runat="Server" debug="true">void Page_Load(Object Sender, EventArgs e){btnKill.Attributes.Add("onclick", "javascript: return confirm('你真的要杀死这个进程吗?');");}private void KillProcess(string processName){ System.Diagnostics.Process myproc= new System.Diagnostics.Process(); //得到所有打开的进程 try{ foreach (Process thisproc in Process.GetProcessesByName(processName)) { if(!thisproc.CloseMainWindow()){ thisproc.Kill(); } } } catch(Exception Exc) { msg.Text+= "杀死" +procname.SelectedItem.Text + "失败!"; }}public void btnKill_Click(object sender, System.EventArgs e) { KillProcess(procname.SelectedItem.Text); msg.Text= procname.SelectedItem.Text +" 已经被杀死。"; }public void btnShow_Click(object sender, System.EventArgs e){ArrayList procList =new ArrayList();string tempName="";int begpos;int endpos; foreach (Process thisProc in System.Diagnostics.Process.GetProcesses()) { tempName=thisProc.ToString(); begpos = tempName.IndexOf("(")+1; endpos= tempName.IndexOf(")"); tempName=tempName.Substring(begpos,endpos-begpos); procList.Add(tempName); } procname.DataSource=procList; procname.DataBind(); }</script></HEAD><body><Basefont Face="Tahoma" /><center><h2>ASP.NET 进程杀死器!</h2><BR><Table cellspacing=2 cellpadding=2 border=0 BGCOLOR="#fFCC66"><form id="frmProc" runat="Server" method="post"><TR><TD><ASP:DropDownList id="procname" runat="server" /></TD><TD>进程名字</TD></TR><TR><TD><asp:button id="btnKill" Text="杀死进程" runat="server" CausesValidation="False" onclick="btnKill_Click" /></TD><TD><asp:button id="btnShow" Text="列出所有进程" runat="server" CausesValidation="False" onclick="btnShow_Click" /></TD></TR></TABLE><center><asp:Label id="msg" runat="server"/></center></form></center></body></HTML>这篇文章不错 关于DataGridView的问题 求解:输入字符串的格式不正确。 乱码 lucene中同一个Document中如何使用两种分词方式。 C#能否开发POS机应用程序,如与扫描条码机接口等?? 回答上一个问题送100分,顶者每人10分,另开一贴结分 调用DLL参数为指针的问题 winform 得到当前窗体获得焦点的控件名 如何在DragEnter事件中知道来源是不是本控件? c#初学者必看 如何将一个进程激活到前台 问一个关于用C#读取关于SQL数据类型的问题
http://www.c-sharpcorner.com/Code/2002/Mar/CaptRunIEInstances.asp
<HTML>
<HEAD>
<% @ Import namespace= "System.Diagnostics" %>
<script language="C#" runat="Server" debug="true">
void Page_Load(Object Sender, EventArgs e){
btnKill.Attributes.Add("onclick", "javascript: return confirm('你真的要杀死这个进程吗?');");
}private void KillProcess(string processName){
System.Diagnostics.Process myproc= new System.Diagnostics.Process();
//得到所有打开的进程
try{
foreach (Process thisproc in Process.GetProcessesByName(processName)) {
if(!thisproc.CloseMainWindow()){
thisproc.Kill();
}
}
}
catch(Exception Exc)
{
msg.Text+= "杀死" +procname.SelectedItem.Text + "失败!";
}
}
public void btnKill_Click(object sender, System.EventArgs e)
{
KillProcess(procname.SelectedItem.Text);
msg.Text= procname.SelectedItem.Text +" 已经被杀死。";
}
public void btnShow_Click(object sender, System.EventArgs e){
ArrayList procList =new ArrayList();
string tempName="";
int begpos;
int endpos;
foreach (Process thisProc in System.Diagnostics.Process.GetProcesses()) {
tempName=thisProc.ToString();
begpos = tempName.IndexOf("(")+1;
endpos= tempName.IndexOf(")");
tempName=tempName.Substring(begpos,endpos-begpos);
procList.Add(tempName);
}
procname.DataSource=procList;
procname.DataBind();
}
</script>
</HEAD>
<body>
<Basefont Face="Tahoma" />
<center><h2>ASP.NET 进程杀死器!</h2><BR>
<Table cellspacing=2 cellpadding=2 border=0 BGCOLOR="#fFCC66">
<form id="frmProc" runat="Server" method="post">
<TR><TD><ASP:DropDownList id="procname" runat="server" /></TD><TD>
进程名字</TD></TR>
<TR><TD>
<asp:button id="btnKill" Text="杀死进程" runat="server" CausesValidation="False" onclick="btnKill_Click" />
</TD>
<TD><asp:button id="btnShow" Text="列出所有进程" runat="server" CausesValidation="False" onclick="btnShow_Click" />
</TD></TR>
</TABLE>
<center><asp:Label id="msg" runat="server"/></center>
</form>
</center>
</body>
</HTML>
这篇文章不错