获取默认浏览器


程序代码:

Imports Microsoft.Win32
Imports Microsoft.VisualBasic.CompilerServices
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MsgBox(GetDefaultWebBrowser.BrowserPath())
    End Sub
    Public Class GetDefaultWebBrowser
        Friend Shared Function BrowserPath() As String
            Dim result As String
            Try
                Dim registryKey As RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\shell\Associations\UrlAssociations\http\UserChoice", False)
                If registryKey IsNot Nothing Then
                    Dim str As String = Conversions.ToString(registryKey.GetValue("ProgId"))
                    registryKey = My.Computer.Registry.ClassesRoot.OpenSubKey(str + "\shell\open\command", False)
                    result = registryKey.GetValue("")
                    Return result
                End If
                registryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Classes\IE.HTTP\shell\open\command", False)
                result = registryKey.GetValue("")
                Return result
            Catch expr_F3 As Exception
                ProjectData.SetProjectError(expr_F3)
                ProjectData.ClearProjectError()
            End Try
            result = "iexplore.exe"
            Return result
        End Function
    End Class
End Class






Please follow WeChat's public account ByCAD