Public Shared Function DefaultBrowserPath() As String

    Dim Key As RegistryKey

    Try
        Key = Registry.ClassesRoot.OpenSubKey(Name:="HTTP\\shell\\open\\command", Writable:=False)

        Dim Path As String = CStr(Key.GetValue(Nothing)).ToLower.Replace("""", "")

        If Not Path.EndsWith(".exe") Then
            Path = Path.Substring(0, Path.LastIndexOf(".exe") + 4)
        End If

        Return Path

    Finally
        If Not Key Is Nothing Then Key.Close()
    End Try

End Function

Public Sub LaunchBrowser(Url as String)

    Dim DefaultBrowserPath As String = Utils.DefaultBrowserPath

    If DefaultBrowserPath Is Nothing Then Throw New NoDefaultBrowserException

    Dim Process As New System.Diagnostics.Process

    Process.StartInfo.FileName = DefaultBrowserPath
    Process.StartInfo.Arguments = InstallUrl
    Process.Start()

End Sub
No comments