Click here to Skip to main content
15,867,453 members
Articles / Desktop Programming / MFC
Article

Launch and control MSIE using IWebBrowser2

Rate me:
Please Sign up or sign in to vote.
3.29/5 (8 votes)
28 Nov 2006 65.8K   6.1K   35   6
A simple interface for launching MSIE and controlling IE components.

Sample output

Introduction

This bit of sample code shows you how to use COM to launch Internet Explorer and through the browser's COM interface control aspects of the browser's interface such as the size of the window, turning on and off the menu bar, the tool bar, and the status bar, and changing the window's icon from the standard Internet Explorer icon to one of your choosing. It also spins IE off in a separate thread from the main thread of the application, and shows you how to determine the browser's version number via the registry.

Using the code

The only thing you should need to use this code is the LaunchBrowser.cpp file, and the prototype "spawn_browser" from that file. In addition, you will need to compile your project with the multi-threaded version of the runtime libraries. I've included a simple console app that shows how to use the interface and call the spawn_browser() function:

spawn_browser("http://www.codeproject.com", 800, 600, hIcon);

Points of Interest

The thread that actually performs the COM interface activity and manipulates the IWebBrowser2 interface is pretty well documented and easy to understand.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
John Klein is an experienced C/C++ and C# developer with an emphisis on WiFi and 802.11 systems. John has 19 years of development and management experience and participated in the development of the IEEE 802.11 wireless protocol.

John currently works at JiWire, Inc. as a principal engineer.

Comments and Discussions

 
QuestionWhy Pin
BMW74015-Jan-09 2:40
BMW74015-Jan-09 2:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.