-
Dec 26th, 2005, 05:09 PM
#1
Thread Starter
Frenzied Member
-
Dec 26th, 2005, 05:24 PM
#2
-
Sep 8th, 2020, 04:29 PM
#3
New Member
Re: [RESOLVED] Get Default Browser!
 Originally Posted by arpan_de
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|