Default Browser In Visual Basic

I’m playing with Visual Studio at the moment because I need to do something that there is no proprietary software for, so I decided to write it myself. I chose Visual Basic (VB) for this.Visual Studio download options

I sat down and started working through a few tutorials to remind myself how it works – it’s ages since I used VB – and after getting bored with lesson 2 I jumped straight to lesson 20-something because that’s where the browser control was. As it happens, you can create a complete browser with VB using a single line of code, and it worked first time. Well, when I loaded Google or my own site, it did. But when I tried to open the site that had prompted me to write the application I am working on in the first place I was confronted by a message informing me that I needed a later browser than IE7!

Bugger. It turns out that even in Visual Studio 2013 the default browser behaviour of the WebBrowser tool is to behave like IE7. And it further turns out that there is no simple setting to change it.

I’m no VB expert, but some of the information I found on the topic was very confusing. Some people say that VB adopts the installed browser settings by default, and others provided poorly explained solutions which didn’t work. However, after a bit of tinkering using several of these references I managed to get VB to open the page I needed.

For anyone who is having the same problem, here’s what you do – and it involves editing the Registry, so take the usual precautions – and remember that unless you are extraordinarily cack-handed you cannot destroy civilisation as we know it by editing the Registry. Just don’t delete anything and you should be fine.

When you create a project in Visual Studio and run it, as I understand it there are basically two .exe files created. Let’s suppose our project is called MyWebThing. If you run the project from within Studio it is compiled into a file called MyWebThing.vshost.exe and this is what is executed during the debug within Studio. A standalone file called MyWebThing.exe is also compiled, and this is what you could run outside of Studio (it’s your finished product, so to speak).

Now, you have to edit the Registry so that named files take on different default behaviours – in this case, the default browser behaviour (there is no global setting or easy way of doing it that I can find). In our case, for our project MyWebThing we need to make sure that both MyWebThing.vshost.exe and MyWebThing.exe are catered for in any Registry changes we make. If you change the name of the project, or create a new one, you’ll have to do this all over again. We need to put new entries – one for each .exe file – in three separate places.

This applies to Windows 7 Ultimate 64-bit. I don’t know if it will work on other versions.

Open RegEdit and navigate to:

HKEY_CURRENT_USER >> Software >> Microsoft >> Internet Explorer >> Main >> FeatureControl >> FEATURE_BROWSER_EMULATION

Create two new DWORD entries, and name them MyWebThing.vshost.exe and MyWebThing.exe (or whatever name you are using instead of MyWebThing). Modify them both to have the hex value 2711.

Now navigate to:

HKEY_LOCAL_MACHINE >> Software >> Microsoft >> Internet Explorer >> MAIN >> FeatureControl >> FEATURE_BROWSER_EMULATION

Create two more DWORD entries with the same names as above, but give them both hex values of 270f.

Finally, navigate to:

HKEY_LOCAL_MACHINE >> Wow6432Node >> Microsoft >> Internet Explorer >> MAIN > FeatureControl >> FEATURE_BROWSER_EMULATION

Create a further two DWORD entries named as before and give them hex values of 2711.

Close RegEdit and run your project again. You should now be able to access all websites.

(Visited 18 times, 1 visits today)