的Process.Start(QUOT; IEXPLORE.EXE")将立即触发发射​​后已退出事件。为什么? [英] Process.Start("IEXPLORE.EXE") immediately fires the Exited event after launch.. why?

查看:320
本文介绍了的Process.Start(QUOT; IEXPLORE.EXE")将立即触发发射​​后已退出事件。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有IE8一个奇怪的问题安装在XP。我试图用C#中System.Diagnostics.Process.Start方法来启动IE浏览器。我不得不陷阱要求IE的退出事件,并做一些操作。但我结束了在一个相当奇怪的问题,在IE浏览器将立即触发发射​​后退出的事件。

i have a strange problem with IE8 installed in xp. i was trying to launch IE using an System.Diagnostics.Process.Start method in c#. And i have a requirement to trap the exited event of the IE and do some operation. But i ended up in a rather strange problem where the IE immediately fires the exited event after launch.

这是示例代码

     Process objProcess = Process.Start("IEXPLORE.EXE", "http://google.com");

     if (objProcess != null)
    {
        objProcess.EnableRaisingEvents = true;
        objProcess.Exited += new EventHandler(myProcess_Exited);        
    }

    public  static void myProcess_Exited(object sender, System.EventArgs e)
    {
        MessageBox.Show("You exited");
    }



但上面的代码laucnching不同的过程,当完美的作品(如:记事本),并它激发当我关闭exe文件的退出事件。

But the above code perfectly works when laucnching different process (ex:notepad) and it fires the exit event when i close the exe.

这只是给问题推出IE 8.有人能澄清我的问题是什么?

this only gives problem launching IE 8. Can someone clarify me what is the problem??

更新

大多数朋友说我的文章,说你为什么不能只用一个网址?为什么用IE坚守?

Most friends replied my post and saying why you can't just use an URL? why stick with IE?

这里的原因

的最终目的应用程序是从Windows应用程序启动一个网址,并在IE浏览器工作时会隐藏一个exe。并显示在关闭IE浏览器后,该exe文件。

the ultimate aim of the app is to launch an URL from the windows application and will hide an exe when working on the IE. And show the exe after closing the IE.

感谢

推荐答案

最有可能的是,你有IE已经运行的一个过程,所以当您尝试再次启动它作为一个新的进程,它看起来有IE浏览器的运行已经,告诉它用户启动一个新窗口(所以最初的IE浏览器将创建一个新的窗口,而不是一个新的)并退出

Most probably is that you have IE already running as a process, so when you try to launch it again as a new process it looks that there are IE running already, tells it that user initiated a new window (so the initial IE will create a "new" window rather than a new one) and exit.

可能的解决方法:
试着以-nomerge命令行选项的过程:

Possible solution: try starting the process with "-nomerge" command line option:

    Process objProcess = Process.Start("IEXPLORE.EXE", "-nomerge http://google.com/");



有趣的观察 objProcess.ExitCode (对于IE8至少),如果退出控制权传递给另一个实例将等于 0 1 ,如果它实际上是由用户关闭。

Interesting observation: objProcess.ExitCode (for IE8 at least) will be equal to 0 if exited passing control to another instance, and 1 if it was actually closed by user.

这篇关于的Process.Start(QUOT; IEXPLORE.EXE")将立即触发发射​​后已退出事件。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆