Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '########################################################
- ' Credits 3DotDev from http://3dotdevcoder.blogspot.fr/
- '########################################################
- Public Shared Function GetDefaultBrowserPath() As String
- Dim defaultBrowserPath As String = String.Empty
- Dim regkey As RegistryKey = Nothing
- Try
- regkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\shell\Associations\UrlAssociations\http\UserChoice", False)
- If regkey IsNot Nothing Then
- Dim ProgId = regkey.GetValue("Progid").ToString()
- regkey = Registry.ClassesRoot.OpenSubKey(ProgId & "\Shell\open\command", False)
- defaultBrowserPath = If(Not regkey Is Nothing,
- regkey.GetValue("").ToString(),
- Registry.ClassesRoot.OpenSubKey("HTTP\Shell\open\command", False).GetValue("").ToString())
- Else
- defaultBrowserPath = Registry.ClassesRoot.OpenSubKey("HTTP\Shell\open\command", False).GetValue("").ToString()
- End If
- Catch ex As Exception
- Finally
- If Not regkey Is Nothing Then regkey.Close()
- End Try
- Return CleanupPath(defaultBrowserPath)
- End Function
- Private Shared Function CleanupPath(path$) As String
- path = path.ToLower().Replace("""", "")
- If Not path.EndsWith(".exe") Then
- path = path.Substring(0, path.LastIndexOf(".exe", StringComparison.Ordinal) + ".exe".Length)
- End If
- Return path
- End Function
- '############################### Vous pouvez exécuter une URL dans votre navigateur par défaut ###########################
- Public Shared sub ExecUrl()
- Process.Start(GetDefaultBrowserPath,"http://3dotdevcoder.blogspot.fr")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement