RegWin9X




Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal _
samDesired As Long, phkResult As Long) As Long

Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType _
As Long, lpData As Any, lpcbData As Long) As Long

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Function sdaGetRegEntry(strKey As String, strSubKeys As String, strValName _
As String, lngType As Long) As String
On Error GoTo sdaGetRegEntry_Err

Dim lngResult As Long, lngKey As Long
Dim lngHandle As Long, lngcbData As Long
Dim strRet As String

Select Case strKey
Case "HKEY_CLASSES_ROOT": lngKey = &H80000000
Case "HKEY_CURRENT_CONFIG": lngKey = &H80000005
Case "HKEY_CURRENT_USER": lngKey = &H80000001
Case "HKEY_DYN_DATA": lngKey = &H80000006

Case "HKEY_LOCAL_MACHINE": lngKey = &H80000002
Case "HKEY_PERFORMANCE_DATA": lngKey = &H80000004
Case "HKEY_USERS": lngKey = &H80000003
Case Else: Exit Function
End Select

If Not ERROR_SUCCESS = RegOpenKeyEx(lngKey, strSubKeys, 0&, KEY_READ, lngHandle) Then Exit Function

lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)
strRet = Space(lngcbData)
lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)

If Not ERROR_SUCCESS = RegCloseKey(lngHandle) Then lngType = -1&

sdaGetRegEntry = strRet

sdaGetRegEntry_Exit:
On Error GoTo 0
Exit Function

sdaGetRegEntry_Err:
lngType = -1&
MsgBox Err & "> " & Error$, 16, "GenUtils/sdaGetRegEntry"
Resume sdaGetRegEntry_Exit

End Function

The Windows 95 and Windows NT Registries are the most useful
things when using your own applications. They allow you to
create Registry INIs, and even how to do your own File Types,
and how to give them your own icons (read more about that here).

Just add this code to an external Module's General
Declarations Section:











( regwin9x.html )- by Paolo Puglisi - Modifica del 17/12/2023