{"id":15884,"date":"2014-06-27T22:23:44","date_gmt":"2014-06-27T21:23:44","guid":{"rendered":"https:\/\/www.diaryofanadi.co.uk\/?p=15884"},"modified":"2014-06-27T22:23:44","modified_gmt":"2014-06-27T21:23:44","slug":"default-browser-in-visual-basic","status":"publish","type":"post","link":"https:\/\/diaryofanadi.co.uk\/?p=15884","title":{"rendered":"Default Browser In Visual Basic"},"content":{"rendered":"<p>I\u2019m 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.<img decoding=\"async\" title=\"Visual Studio download options\" style=\"--smush-placeholder-width: 524px; --smush-placeholder-aspect-ratio: 524\/158;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: left; padding-top: 0px; padding-left: 0px; margin: 5px 10px 5px 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"Visual Studio download options\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2014\/06\/vs_ad.gif\" width=\"524\" align=\"left\" height=\"158\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"><\/p>\n<p>I sat down and started working through a few tutorials to remind myself how it works &#8211; it\u2019s ages since I used VB &#8211; and after getting bored with lesson 2 I jumped straight to lesson 20-something because that\u2019s 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!<\/p>\n<p>Bugger. It turns out that even in Visual Studio 2013 the default browser behaviour of the <strong>WebBrowser<\/strong> tool is to behave like IE7. And it further turns out that there is no simple setting to change it.<\/p>\n<p>I\u2019m 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\u2019t work. However, after a bit of tinkering using several of these references I managed to get VB to open the page I needed.<\/p>\n<p>For anyone who is having the same problem, here\u2019s what you do &#8211; and it involves editing the Registry, so take the usual precautions &#8211; and remember that unless you are extraordinarily cack-handed you cannot destroy civilisation as we know it by editing the Registry. Just don\u2019t delete anything and you should be fine.<\/p>\n<p>When you create a project in Visual Studio and run it, as I understand it there are basically two .exe files created. Let\u2019s suppose our project is called <strong>MyWebThing.<\/strong> If you run the project from within Studio it is compiled into a file called <strong>MyWebThing.vshost.exe<\/strong> and this is what is executed during the debug within Studio. A standalone file called <strong>MyWebThing.exe<\/strong> is also compiled, and this is what you could run outside of Studio (it\u2019s your finished product, so to speak).<\/p>\n<p>Now, you have to edit the Registry so that named files take on different default behaviours &#8211; 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 <strong>MyWebThing<\/strong> we need to make sure that both <strong>MyWebThing.vshost.exe<\/strong> and <strong>MyWebThing.exe<\/strong> are catered for in any Registry changes we make. If you change the name of the project, or create a new one, you\u2019ll have to do this all over again. We need to put new entries &#8211; one for each .exe file &#8211; in three separate places.<\/p>\n<p><strong>This applies to Windows 7 Ultimate 64-bit. I don\u2019t know if it will work on other versions.<\/strong><\/p>\n<p>Open RegEdit and navigate to:<\/p>\n<p><font face=\"Courier New\"><strong>HKEY_CURRENT_USER &gt;&gt; Software &gt;&gt; Microsoft &gt;&gt; Internet Explorer &gt;&gt; Main &gt;&gt; FeatureControl &gt;&gt; FEATURE_BROWSER_EMULATION<\/strong><\/font><\/p>\n<p>Create two new DWORD entries, and name them <strong>MyWebThing.vshost.exe<\/strong> and <strong>MyWebThing.exe <\/strong>(or whatever name you are using instead of MyWebThing). Modify them both to have the hex value 2711.<\/p>\n<p>Now navigate to:<\/p>\n<p><font face=\"Courier New\"><strong>HKEY_LOCAL_MACHINE &gt;&gt; Software &gt;&gt; Microsoft &gt;&gt; Internet Explorer &gt;&gt; MAIN &gt;&gt; FeatureControl &gt;&gt; FEATURE_BROWSER_EMULATION<\/strong><\/font><\/p>\n<p>Create two more DWORD entries with the same names as above, but give them both hex values of 270f.<\/p>\n<p>Finally, navigate to:<\/p>\n<p><font face=\"Courier New\"><strong>HKEY_LOCAL_MACHINE &gt;&gt; Wow6432Node &gt;&gt; Microsoft &gt;&gt; Internet Explorer &gt;&gt; MAIN &gt; FeatureControl &gt;&gt; FEATURE_BROWSER_EMULATION<\/strong><\/font><\/p>\n<p>Create a further two DWORD entries named as before and give them hex values of 2711.<\/p>\n<p>Close RegEdit and run your project again. You should now be able to access all websites.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019m 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. I sat down and started working through a few tutorials to remind myself how it works &#8211; it\u2019s ages since [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[90],"tags":[],"class_list":["post-15884","post","type-post","status-publish","format-standard","hentry","category-computer-tech-related"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/15884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15884"}],"version-history":[{"count":0,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/15884\/revisions"}],"wp:attachment":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}