Hack Forums
[.NET] Change default browser - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Change default browser (/showthread.php?tid=4702543)



Change default browser - Shikatanai - Feb 24, 2015

Add New Class

Code:
Code
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"
            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 11
                    If IgnoreIDocDirective Then
                        value = 11001
                    Else
                        value = 11000
                    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



* - paul8819 - May 19, 2015

great, please send me youre skype or jabber by pm. I cant send, I think you can help me


* - Only3 - May 19, 2015

and the credit goes to 😊


* - Shikatanai - Jun 5, 2015

Sorry. but I forgot where I get that code.


* - frawg - Jun 6, 2015

(Jun 5, 2015 07:54 PM)Shikatanai Wrote:  Sorry. but I forgot where I get that code.

http://www.vbforums.com/showthread.php?775297-Popup-message-%28Your-Browser-is-not-supported%29-in-my-Webbrowser-VB-net2010&p=4751775&viewfull=1#post4751775


* - Shikatanai - Jun 11, 2015

(Jun 6, 2015 12:01 AM)frawg Wrote:  http://www.vbforums.com/showthread.php?775297-Popup-message-%28Your-Browser-is-not-supported%29-in-my-Webbrowser-VB-net2010&p=4751775&viewfull=1#post4751775

Thank you 🀝 🀝


* - ΔΔΔΔΔΔ - Jun 12, 2015

You should always give the credits if you are scarping code from elsewhere.Anyways this might come in handy


* - 3270 - Jun 12, 2015

Can you give me an example on why you would use another webbrowser? If you're trying to make bots, I don't think webbrowser is the way to go! You should look into httpwebrequests.


* - NETExplorer - Jun 12, 2015

(Jun 12, 2015 01:52 PM)3270 Wrote:  Can you give me an example on why you would use another webbrowser? If you're trying to make bots, I don't think webbrowser is the way to go! You should look into httpwebrequests.

Even though you are correct, do you understand what this thread is about?


* - He B TeMy - Jun 12, 2015

(Jun 12, 2015 02:01 PM)PatPositron Wrote:  Even though you are correct, do you understand what this thread is about?

No he doesn't and neither does OP


* - r3fc4t - Jun 12, 2015

thanks dude !!!!!! i'm so thankfull


* - iLogicβ„’ - Jun 16, 2015

Thank you for this tutorial - you helped me πŸ™‚


* - Shikatanai - Jun 17, 2015

No problem mate. 🀝