I am posting this in response to those who ask about replacing the webbrowser (WB) control’s default browser. You cannot ask the WB control to use a different browser, it is hardwired to use the current version of Microsoft’s Internet Explorer that is installed on the target computer.
It may appear that the WB control is using an older version than is installed; this is not the case. Microsoft in their infinite wisdom made the decision to make IE 7 the default-rendering mode for all applications that use the WB control. This can be observed by visiting this website:
This can be overridden by adding the application name to the registry key:
Doing this can be a royal pain in the butt. Especially when developing a program as you would need to make one entry for “ApplicationName.exe” and one for “ApplicationName.vshost.exe” (for debugging under VS).
This code adds and deletes the registry entry on the fly for you. Just add it to your project. That is all that needs to be done. It automatically makes the registry changes for you.
Disclaimer: This code makes changes to the registry on Windows based systems. This is an inherently dangerous operation. The author assumes no responsibity for issues related to your use of this code. Use at your own risk.
Namespace My Partial Friend Class MyApplication Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup CreateBrowserKey() End Sub Private Sub MyApplication_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown ' I don't like applications that defecate in the registry and then don't cleanup their own mess ' so remove the key RemoveBrowerKey() End Sub Private Const BrowserKeyPath As String = "\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION" Private Sub CreateBrowserKey(Optional ByVal IgnoreIDocDirective As Boolean = False) Dim basekey As String = Microsoft.Win32.Registry.CurrentUser.ToString Dim value As Int32 Dim thisAppsName As String = My.Application.Info.AssemblyName & ".exe" ' Value reference: http://msdn.microsoft.com/en-us/library/ee330730%28v=VS.85%29.aspx ' IDOC Reference: http://msdn.microsoft.com/en-us/library/ms535242%28v=vs.85%29.aspx Select Case (New WebBrowser).Version.Major Case 8 If IgnoreIDocDirective Then value = 8888 Else value = 8000 End If Case 9 If IgnoreIDocDirective Then value = 9999 Else value = 9000 End If Case 10 If IgnoreIDocDirective Then value = 10001 Else value = 10000 End If Case Else Exit Sub End Select Microsoft.Win32.Registry.SetValue(Microsoft.Win32.Registry.CurrentUser.ToString & BrowserKeyPath, _ Process.GetCurrentProcess.ProcessName & ".exe", _ value, _ Microsoft.Win32.RegistryValueKind.DWord) End Sub Private Sub RemoveBrowerKey() Dim key As Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(BrowserKeyPath.Substring(1), True) key.DeleteValue(Process.GetCurrentProcess.ProcessName & ".exe", False) End Sub End Class 'MyApplication End Namespace 'My