here's what i used. if you want to look up other HKEYs you'll need to find
the appropriate value.
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As
Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As
Long, lpType As Long, ByVal lpData As String, _
lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long)
As Long
Public Const HKEY_CURRENT_USER = &H80000001
Public Const REG_BINARY As Long = 3
Public Const REG_DWORD As Long = 4
Public Function ReadRegistry(ByVal Group As Long, ByVal Section As String,
ByVal Key As String) As String
''''''use this somewhere appropriate in your app to get your value
' sVal = ReadRegistry(HKEY_CURRENT_USER, "Software\ODBC\ODBC.INI\PHINMS",
"Server")
Dim lResult As Long, lKeyValue As Long, lDataTypeValue As Long,
lValueLength As Long, sValue As String, td As Double
Dim TStr1 As String, TStr2 As String, i As Integer
On Error Resume Next
lResult = RegOpenKey(Group, Section, lKeyValue)
sValue = Space$(2048)
lValueLength = Len(sValue)
lResult = RegQueryValueEx(lKeyValue, Key, 0&, lDataTypeValue, sValue,
lValueLength)
If (lResult = 0) And (Err.Number = 0) Then
If lDataTypeValue = REG_DWORD Then
td = Asc(Mid$(sValue, 1, 1)) _
+ &H100& * Asc(Mid$(sValue, 2, 1)) + &H10000 *
Asc(Mid$(sValue, 3, 1)) + &H1000000 _
* CDbl(Asc(Mid$(sValue, 4, 1)))
sValue = Format$(td, "000")
End If
If lDataTypeValue = REG_BINARY Then
' Return a binary field as a hex string (2 chars per byte)
TStr2 = ""
For i = 1 To lValueLength
TStr1 = Hex(Asc(Mid(sValue, i, 1)))
If Len(TStr1) = 1 Then TStr1 = "0" & TStr1
TStr2 = TStr2 + TStr1
Next
sValue = TStr2
Else
sValue = Left$(sValue, lValueLength - 1)
End If
Else
sValue = "Not Found"
End If
lResult = RegCloseKey(lKeyValue)
ReadRegistry = sValue
End Function