private void 结束进程ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (MessageBox.Show("警告:终止进程会导致不希望发生的结果,\r包括数据丢失和系统不稳定。在被终止前,\r进程将没有机会保存其状态和数据。确实\r想终止该进程吗?", "任务管理器警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
string ProcessName = listView1.SelectedItems[0].Text;
Process[] MyProcess = Process.GetProcessesByName(ProcessName);
MyProcess[0].Kill();
getProcessInfo();
}
else
{ }
}
catch
{
string ProcessName = listView1.SelectedItems[0].Text;
Process[] MyProcess1 = Process.GetProcessesByName(ProcessName);
Process MyProcess = new Process();
//设定程序名
MyProcess.StartInfo.FileName = "cmd.exe";
//关闭Shell的使用
MyProcess.StartInfo.UseShellExecute = false;
//重定向标准输入
MyProcess.StartInfo.RedirectStandardInput = true;
//重定向标准输出
MyProcess.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
MyProcess.StartInfo.RedirectStandardError = true;
//设置不显示窗口
MyProcess.StartInfo.CreateNoWindow = true;
//执行强制结束命令
MyProcess.Start();
MyProcess.StandardInput.WriteLine("ntsd -c q -p " + (MyProcess1[0].Id).ToString());
MyProcess.StandardInput.WriteLine("Exit"); getProcessInfo();
}
}关闭进程用MyProcess[0].Kill();
这个不是就好了吗
红色字体是干什么的...求解释....谢谢...
{
try
{
if (MessageBox.Show("警告:终止进程会导致不希望发生的结果,\r包括数据丢失和系统不稳定。在被终止前,\r进程将没有机会保存其状态和数据。确实\r想终止该进程吗?", "任务管理器警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
string ProcessName = listView1.SelectedItems[0].Text;
Process[] MyProcess = Process.GetProcessesByName(ProcessName);
MyProcess[0].Kill();
getProcessInfo();
}
else
{ }
}
catch
{
string ProcessName = listView1.SelectedItems[0].Text;
Process[] MyProcess1 = Process.GetProcessesByName(ProcessName);
Process MyProcess = new Process();
//设定程序名
MyProcess.StartInfo.FileName = "cmd.exe";
//关闭Shell的使用
MyProcess.StartInfo.UseShellExecute = false;
//重定向标准输入
MyProcess.StartInfo.RedirectStandardInput = true;
//重定向标准输出
MyProcess.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
MyProcess.StartInfo.RedirectStandardError = true;
//设置不显示窗口
MyProcess.StartInfo.CreateNoWindow = true;
//执行强制结束命令
MyProcess.Start();
MyProcess.StandardInput.WriteLine("ntsd -c q -p " + (MyProcess1[0].Id).ToString());
MyProcess.StandardInput.WriteLine("Exit"); getProcessInfo();
}
}关闭进程用MyProcess[0].Kill();
这个不是就好了吗
红色字体是干什么的...求解释....谢谢...
解决方案 »
- VS 2003 Winform DataGrid 问题
- 难度挺大,在考勤系统中怎么样从刷卡数据中判断是否存在代拉卡现象
- 请问:如何把mdi父窗口工作区顶端的“凹下”效果改为“平面”?
- 请问如何判断一个类是否存在呀?谢谢,请帮下忙!
- 请教一个用正则根据取出input元素的ID取出value值。
- windows服务能向外提供API吗?
- 高手们,请教个问题,关于Pinvoke的
- 请推荐几本C#入门的好书.
- @@@@@主表与关联的表增么在同一个DataGrid中显示@@@@@
- 急,在线,一个关于Invoke调用方法的问题
- C#添加XML节点问题,急救!
- 我想编写一个能自动写笑话的软件,如何下手,请大家畅所欲言?
string ProcessName = listView1.SelectedItems[0].Text;
Process[] MyProcess1 = Process.GetProcessesByName(ProcessName);
Process MyProcess = new Process();
//设定程序名
MyProcess.StartInfo.FileName = "cmd.exe";
//关闭Shell的使用
MyProcess.StartInfo.UseShellExecute = false;
//重定向标准输入
MyProcess.StartInfo.RedirectStandardInput = true;
//重定向标准输出
MyProcess.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
MyProcess.StartInfo.RedirectStandardError = true;
//设置不显示窗口
MyProcess.StartInfo.CreateNoWindow = true;
//执行强制结束命令
MyProcess.Start();
MyProcess.StandardInput.WriteLine("ntsd -c q -p " + (MyProcess1[0].Id).ToString());
MyProcess.StandardInput.WriteLine("Exit");
求解释这几句