Results 1 to 3 of 3

Thread: [RESOLVED] Get Default Browser!

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Resolved [RESOLVED] Get Default Browser!

    Using VB6, how do I find out which browser has been set as the default browser in the user's machine?
    Last edited by arpan_de; Jan 9th, 2006 at 09:54 PM.


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  2. #2

  3. #3
    New Member
    Join Date
    May 2020
    Posts
    11

    Re: [RESOLVED] Get Default Browser!

    Quote Originally Posted by arpan_de View Post
    Using VB6, how do I find out which browser has been set as the default browser in the user's machine?
    i've found researching how to get the default browser, and you can get the information using this funtion
    tested on Windows 10 hope this save some time to someone


    Public Function GetBrowser() As String
    Dim hKey As Long
    Dim nBytes As Long
    Dim nStart As Long
    Dim nEnd As Long
    Static retval As String
    Static retval2 As String
    Dim HttpsAssoc As String

    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const KEY_READ As Long = &H20019
    Const ERROR_SUCCESS As Long = 0&
    ' Const HttpAssoc As String = "https\shell\open\command"
    HttpsAssoc = "\shell\open\command"
    Const userchoicehttps As String = "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice"

    ' Const HttpAssoc As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\HTTP\shell\open\command"
    ' No need to hit the registry and parse more than once.
    If RegOpenKeyEx(HKEY_CURRENT_USER, userchoicehttps, 0&, KEY_READ, hKey) = ERROR_SUCCESS Then
    ' Determine required buffer length of default value.

    If RegQueryValueEx(hKey, "ProgID", 0&, ByVal 0&, ByVal retval2, nBytes) = ERROR_SUCCESS Then
    retval2 = Space$(nBytes)
    If RegQueryValueEx(hKey, "ProgID", 0&, ByVal 0&, ByVal retval2, nBytes) = ERROR_SUCCESS Then
    ' Trim NULL and return successful query!
    retval2 = Left(retval2, nBytes - 1)
    End If
    End If
    ' Clean up.
    Call RegCloseKey(hKey)
    End If

    If Len(retval2) = 0 Then
    retval2 = vbNullString
    Else
    HttpsAssoc = retval2 & "\shell\open\command"
    End If

    If Len(retval) = 0 Then
    ' Open the key that holds HTTP associated application.
    If RegOpenKeyEx(HKEY_CLASSES_ROOT, HttpsAssoc, 0&, KEY_READ, hKey) = ERROR_SUCCESS Then
    ' Determine required buffer length of default value.

    If RegQueryValueEx(hKey, retval, 0&, ByVal 0&, ByVal retval, nBytes) = ERROR_SUCCESS Then
    retval = Space$(nBytes)
    If RegQueryValueEx(hKey, vbNullString, 0&, ByVal 0&, ByVal retval, nBytes) = ERROR_SUCCESS Then
    ' Trim NULL and return successful query!
    retval = Left(retval, nBytes - 1)
    End If
    End If
    ' Clean up.
    Call RegCloseKey(hKey)
    End If

    ' Clean up results...
    ' Start by looking for the first two quote characters.
    nStart = InStr(retval, """")
    nEnd = InStr(nStart + 1, retval, """")
    ' Do we have two quotes at two locations?
    If nStart = 1 And nEnd > 1 Then
    ' Strip out the path. Example:
    ' "C:\Program Files\Internet Explorer\iexplore.exe" -nohome
    retval = Mid$(retval, nStart + 1, nEnd - nStart - 1)
    Else

    nEnd = InStrRev(retval, "")
    If nEnd Then
    nEnd = InStr(nEnd, retval, " ")
    If nEnd Then
    retval = Left$(retval, nEnd - 1)
    End If
    End If
    End If
    End If

    ' Return results
    GetBrowser = retval
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width