using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication2
{
class Program
{
static void Main()
{
Test a = new Test();
Console.ReadKey();//保证这个进程不结束
}
}
class Test
{
private Process myProcess = new Process();
public Test()
{
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.EnableRaisingEvents = true;
myProcess.Exited += new EventHandler(Process_Exited);
myProcess.Start();
}
public void Process_Exited(object sender, EventArgs e)
{
try
{
myProcess.WaitForExit();
Console.WriteLine("结束时间: {0}\r\n" +
"终止代码: {1}\r\n", myProcess.ExitTime, myProcess.ExitCode);
}
finally
{
myProcess.Refresh();
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.EnableRaisingEvents = true;
myProcess.Exited += new EventHandler(Process_Exited);
myProcess.Start();
}
}
}
}
功能:
始终打开IE窗口
通过任务管理器结束后也照样
本文介绍了一个简单的C#程序,该程序能够确保Internet Explorer浏览器始终处于运行状态。即使用户通过任务管理器关闭了IE窗口,程序也能自动重新启动浏览器。
1490

被折叠的 条评论
为什么被折叠?



