2
我试图为IE创建一个插件安装程序,所以在安装前继续IE进程必须杀死。但是当我在IE进程上执行kill()
方法时,我得到了“访问被拒绝”的错误。自定义操作检查IE是否正在运行,然后关闭它当
什么是最好的方法呢?
我安装代码:
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
if (LaunchOnBeforeInstall())
{
foreach (var process in Process.GetProcesses())
{
if (!process.ProcessName.StartsWith("iexplore"))
{
process.Kill();
}
}
base.OnBeforeInstall(savedState);
}
else
{
throw new Exception("You cancelled the installation.");
}
}
public bool LaunchOnBeforeInstall()
{
var result = MessageBox.Show("All instance of IE will be close", "Warning", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question);
return result != DialogResult.Cancel;
}
?也可能值得注意的是,IE的新版本使用线程选项卡,每个选项卡都显示为一个进程,因此您必须杀死所有实例。 – kyndigs 2011-05-10 11:04:03