ARTICLE
Creating an instance of Internet Explorer in VB.NET
Tags: .NET, Browser Control, Creating Instance, IE, Instance in Internet Explorer, Internet, Internet Explorer, Internet Explorer in VB.NET., Navigate, OpenBrowser, SHDocVw.dll, System32 Directory, TextBox, VB.NET, Web Application, Web Browser
I was trying to write a program that opened an instance of Internet Explorer in a separate window, rather than use the Browser control that comes with the .NET platform.Unfortunately, it proved almost impossible to find any references to the interfaces necessary to do the job. Here is the souce code that does the same.
Download
Files:
I was trying to write a program that opened an instance of Internet Explorer in a separate window, rather than use the Browser control that comes with the .NET platform.
Unfortunately, it proved almost impossible to find any references to the interfaces necessary to do the job.
This is a very simple program that allows the user to type a URL into a textbox, and then opens IE directly to that URL.
This only works with IE4 and above.
The heart of the code is exposing the IWebBrowserApp interface. This interface is located in the SHDocVw.dll, which can be found (on Win2K/Xp) in the System32 directory.
The source code is simple:
Imports SHDocVw
Sub OpenBrowser(ByVal url As String) '
Dim o As Object = Nothing
Dim ie As New SHDocVw.InternetExplorerClass
Dim wb As IWebBrowserApp = CType(ie, IWebBrowserApp)
wb.Visible = True
'Do anything else with the window here that you wish
wb.Navigate(url, o, o, o, o)
End Sub 'OpenBrowser
I hope this is useful to others.