Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Public Function GetKeyValue(strKey As String, strValue As String) As String
Const cstrRoutineName As String = "GetKeyValue"
Const clngHKCU As Long = &H80000001
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
' Return code constants
Const ERROR_NONE = 0
Const ERROR_BADDB = 1
Const ERROR_BADKEY = 2
Const ERROR_CANTOPEN = 3
Const ERROR_CANTREAD = 4
Const ERROR_CANTWRITE = 5
Const ERROR_OUTOFMEMORY = 6
Const ERROR_ARENA_TRASHED = 7
Const ERROR_ACCESS_DENIED = 8
Const ERROR_INVALID_PARAMETERS = 87
Const ERROR_NO_MORE_ITEMS = 259
Dim lngR As Long ' Resultcode
Dim lngH As Long ' Handle
Dim strX As String ' returned value
Dim lngX As Long ' returned length
Dim lngT As Long ' Key type
lngR = RegOpenKeyEx(clngHKCU, strKey, 0, KEY_ALL_ACCESS, lngH)
strX = vbNullString
If (lngR = ERROR_NONE) Then
'key opened successfully
strX = String(1024, 0)
lngX = Len(strX)
' Get key value
lngR = RegQueryValueEx(lngH, strValue, 0, lngT, strX, lngX)
If lngR = 0 Then
' Value returned
If Asc(Mid(strX, lngX, 1)) = 0 Then lngX = lngX - 1
strX = Left(strX, lngX)
End If
End If
lngR = RegCloseKey(lngH)
GetKeyValue = strX
End Function