Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Launch and control MSIE using IWebBrowser2

0.00/5 (No votes)
28 Nov 2006 1  
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