How to connwct a running instance of IE from a VC++ application?

I want a VC++ program to connect with a running instance of IE but couldn't figure out how to do that. Note: I don't want an embedded browser; and I need a control so I can get html data from the IE and I can pass a URL to IE.

yzmaoAsked:
Who is Participating?
 
chensuConnect With a Mentor Commented:
HOWTO: Connecting to a Running Instance of Internet Explorer
http://support.microsoft.com/support/kb/articles/Q176/7/92.ASP

IEHelper-Attaching to Internet Explorer 4.0 using a Browser Helper Object
http://support.microsoft.com/support/kb/articles/q179/2/30.asp
0
 
yzmaoAuthor Commented:
Hi chensu,

Thank you very much for your help. Did you know that the first article doesn't work? ...well, Visual Basic code works, but Visual C++ doesn't. The problem is, the code couldn't identify the IE window.

I'm going to try using IEHelper.
0
 
chensuCommented:
It works for me. Which version of IE do you have?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
yzmaoAuthor Commented:
My IE is 4.0.

I don't know why. Using the code (in the first article) my program can identify Windows Explorer but not IE. And, it can create an instance of WebBrowser2, display a web site in the right panel of the Windows Explorer when using "navigate" function.

I'm trying to use IEHelper now.

Any advise will be very helpful (no matter to which approach)!

Thank you very much!

Yours,

Y. Z. Mao
0
 
chensuCommented:
"The previous method for connecting to a running instance of the Internet Explorer does not work if Shell Integration is not installed or if "Browse in a new process" is selected in Internet Explorer 4.0.

If these factors cannot be controlled, there is still one possible method that may work. A browser helper object can be written to register Internet Explorer 4.0 in the running object table (ROT). There are many implementations possible here depending on how the application is to determine the instance of Internet Explorer with which to connect. This is just one possible solution: The browser helper object, having access to the object model of the instance of Explorer that launched it, would determine if this is the instance of the browser that should be registered in the running object table."
0
 
yzmaoAuthor Commented:
IE cannot register itself in the Running Object Table, that is why ShellWindows can not find the instance of an IE.

The Browser Helper object attaches a dll to IE 4.0. It creates a way to control the IE. That is good. But there is one thing not that good: every time you open a Windows Explorer or an IE, a dialog appears -- it cannot distinguish Windows' Explorer from IE. So it is a "semi-control" at most.

And, the Helper object didn't have a function to get document (IWebBrowser->get_Document()) yet.

I see your message is from Q176792. Tell me something more about the issue.
0
 
chensuCommented:
>IE cannot register itself in the Running Object Table, that is why ShellWindows can not find the instance of an IE.

ShellWindows does not search ROT. Otherwise, it won't work at all. You said VB version was working for you.

>And, the Helper object didn't have a function to get document (IWebBrowser->get_Document()) yet.

As long as you can get the IWebBrowser2 interface, you can call the get_Document method.

>I see your message is from Q176792. Tell me something more about the issue.

Check the "Browse in a new process" option of your IE.
0
 
yzmaoAuthor Commented:
Excellent! Now it works (using the first approach)!

Need to uncheck the "Browse in a new process".

Thank you very much! Merry Christmas and good luck in the new Century!

yzmao
0
All Courses

From novice to tech pro — start learning today.