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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.