Visual Basic Classic
--
Questions
--
Followers
Top Experts
ie - sRtn = "C:\Program Files\Internet Explorer\iexplore.exe"
VB.NET 2005 - This needs to support Win Vista 32bit
Thanks
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
As soon as I test it I'll give you the points
<<registryKey = Registry.ClassesRoot.OpenS
I did a google on it and found that out too just earlier






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
If you just need to find *a* browser, it will work fine. If you want to find the default browser it will give erroneous results for a lot of people.
Perhaps a better way to do it is as follows:
Private Function GetDefaultBrowserPath() As String
  Dim StartMenuInternetKey As RegistryKey = Registry.LocalMachine.Open
  Dim InternetProgram As String = StartMenuInternetKey.GetVa
  Return StartMenuInternetKey.OpenS
End Function
This will get the Browser that is pinned to the top of most peoples Start Menu. I think it's probably Windows XP only though.
  ''' <summary>
  ''' Gets the path to the default browser from the registry.
  ''' </summary>
  ''' <returns>The path to the default browser. null (Nothing in VB) if not set.</returns>
  Function GetDefaultBrowserPath() As String
    Dim startMenuInternetSubKey As String = "Software\Clients\StartMen
    ' Find the key in the registry that contains the relevent default browser information.
    ' This is either in the current user if they have a different one to the local machine, otherwise
    ' in local machine.
    Dim startMenuInternetKey As RegistryKey = Registry.CurrentUser.OpenS
    ' If the current user does not have a default browser set, use the default browser for the local machine.
    If startMenuInternetKey Is Nothing Then
      startMenuInternetKey = Registry.LocalMachine.Open
    End If
    ' Get the name of the default clients subkey and get the shell open command. This may be null if, for some
    ' strange reason, it does not exist.
    Dim defaultBrowser As Object = startMenuInternetKey.GetVa
    ' Handle null cases (this is odd and shouldn't really happen. But theoretically it might.
    If defaultBrowser Is Nothing Then
      Return GetDefaultBrowserPathFromH
    End If
    Dim defaultBrowserPath As Object = startMenuInternetKey.OpenS
    ' Handle null cases when casting and returning.
    If defaultBrowserPath Is Nothing Then
      Return GetDefaultBrowserPathFromH
    End If
    Return defaultBrowserPath
  End Function
  ''' <summary>
  ''' Gets the path to the browser associated with html files.
  ''' </summary>
  ''' <returns>The path to the browser associated with html files. null (Nothing in VB) if not set.</returns>
  ''' <remarks>Often used as a fallback for GetDefaultBrowserPath.</re
  Function GetDefaultBrowserPathFromH
    ' Used as a fall back method if the normal GetDefaultBrowserPath fails.
    ' Often this is because they are using Windows 98/2000.
    ' Open the registry key that has the command to open the program associated with html files.
    Dim htmlShellOpenKey As RegistryKey = Registry.ClassesRoot.OpenS
    ' If for some reason this key doesn't exist, return null.
    If htmlShellOpenKey == Nothing Then
      Return Nothing
    End If
    Return htmlShellOpenKey.GetValue(
  End Function
One small note regarding  >>I think it's probably Windows XP only though.<<
This program will be run on Vista only - there will be no need to run it on XP or any other OS.
I'll wait for your reply before trying out your second idea. Â :)
I'm happy to reopen this Q to include you in a split as well (after increasing points) so please treat this as if it's still open.
Ryan

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
The following opens the website in the default browser:
Process.Start("http://www.website.com")
Ryan R
 If htmlShellOpenKey == Nothing Then
      Return Nothing
    End If
gives me an error in vb 2012, doesn't like the ==
papaaT555
Visual Basic Classic
--
Questions
--
Followers
Top Experts
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.