How to attach a BHO in currently running IE instance |
| nishant sagar posted at 05-Jul-08 12:57 |
Hi Friends,
How can I attach a Browser Helper Object to a currently running instance of Internet Explorer? Meaning, I don't want to create a new instance of IE after installing my BHO, but rather want it working with the currently running instance.
The scenario is that we have this webpage where we show two buttons, one for "Download Application" and one for "Continue". Initially, the download button will be enabled and the continue button will be shown as disabled.
On download button click user will download and install our application and along with that our BHO. This BHO will check if our application is already installed in the user's machine or not. If it is already installed, we will enable the Continue button and disable the Download button, else, its opposite will be true.
Now it works perfectly if I open a new instance of IE after installing the application. But I need it to take effect from the same old currently running instance of IE from where the user downloaded the application.
After searching a while on internet I am able to get hold of the currently running instance of IE using the following code....
ShellWindows shellWindows = new ShellWindows(); InternetExplorerClass internetExplorer = new InternetExplorerClass();
foreach (object objWindow in shellWindows) { if (objWindow.GetType().ToString() == "SHDocVw.InternetExplorerClass") { //it shows me the type of current instance as of InternetExplorerClass //meaning that of all running windows, IE windows are detected MessageBox.Show(objWindow.GetType().ToString());
//internetExplorer = (InternetExplorerClass)objWindow; //webBrowser = (SHDocVw.WebBrowser)internetExplorer; } }
... and now am searching about how to move further. Any ideas????
Thanks and regards, Nishant
|
|