David,
Here is some code to read the registry under HKEY_LOCAL_MACHINE. I hope you find it useful.
------------------------------------
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(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
On Error GoTo Error_Routine
1 Dim i As Long ' Loop Counter
2 Dim rc As Long ' Return Code
3 Dim hKey As Long ' Handle To An Open Registry Key
4 Dim hDepth As Long '
5 Dim KeyValType As Long ' Data Type Of A Registry Key
6 Dim tmpVal As String ' Tempory Storage For A Registry Key Value
7 Dim KeyValSize As Long ' Size Of Registry Key Variable
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
8 rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
9 If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
10 tmpVal = String$(1024, 0) ' Allocate Variable Space
11 KeyValSize = 1024 ' Mark Variable Size
'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
12 rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
13 If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
14 If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
15 tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
16 Else ' WinNT Does NOT Null Terminate String...
17 tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
18 End If
'------------------------------------------------------------
' Determine Key Value Type For Conversion...
'------------------------------------------------------------
19 Select Case KeyValType ' Search Data Types...
Case REG_SZ ' String Registry Key Data Type
20 KeyVal = tmpVal ' Copy String Value
21 Case REG_DWORD ' Double Word Registry Key Data Type
22 For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
23 KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
24 Next
25 KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
26 End Select
27 GetKeyValue = True ' Return Success
28 rc = RegCloseKey(hKey) ' Close Registry Key
29 Exit Function ' Exit
30 GetKeyError: ' Cleanup After An Error Has Occured...
31 KeyVal = "" ' Set Return Val To Empty String
32 GetKeyValue = False ' Return Failure
33 rc = RegCloseKey(hKey) ' Close Registry Key
Exit_Routine:
Exit Function
Error_Routine:
Debug.Assert False
Err.Raise Err.Number, "frmAbout.GetKeyValue(" & Erl & "

:" & Err.Source, Err.Description
End Function
----------------------------------------
Glyn.