I figured it out
Public Function fncRegistryEnumerate(RegistryRoot As enuRegRootName,
RegistryHive As String) As Variant
On Error GoTo ErrorHandle
Dim ThisFileTime As typeFileTime
Dim hKey As Long
Dim Result As Long
Dim Index As Long
Dim keyname As String
Dim classname As String
Dim keylen As Long
Dim classlen As Long
Dim Message As Variant
Dim Reserved As Long
' Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Control\Print\Printers", 0, KEY_READ, hKey)
' Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"Software\Micromonitors\TrueGasHost\Security\", 0, KEY_READ, hKey)
Result = RegOpenKeyEx(RegistryRoot, RegistryHive, 0, KEY_READ, hKey)
If Result <> ERROR_SUCCESS Then
' MsgBox "Can't open key"
fncRegistryEnumerate = ""
Exit Function
End If
Do
keylen = 2000
classlen = 2000
keyname = String$(keylen, 0)
classname = String$(classlen, 0)
Result = RegEnumKeyEx(hKey, Index, keyname, keylen, Reserved,
classname, classlen, ThisFileTime)
Index = Index + 1
If Result = ERROR_SUCCESS Then
Message(Tools.fncRedimArray(Message, 1)) = Left$(keyname, keylen)
End If 'Result = ERROR_SUCCESS
Loop While Result = ERROR_SUCCESS
fncRegistryEnumerate = Message
RegCloseKey hKey
End Function
TW Scannell, MCP
Quote:
> Hello and Thanks in advance.
> I am doing a minor login box for apps that are not networked. I am setting
> up an area in the Registry for Login(key) and Password (value).
> I can write the entry and read a Pasword(Value) if I know the login(Key).
> (RegistryKey in the example)
> How do I find all the Keys / Logins in this section? There has to be a
> method because Regedit32 can do it.
> My function to read if I know the Key:
> Public Function fncRegistryRead(RegistryRoot As enuRegRootName,
RegistryHive
> As String, RegistryKey As String) As String
> On Error GoTo ErrorHandle
> Dim hKey As Long
> Dim strkey As String * 255
> Dim lngSize As Long
> Dim lngType As Long
> Dim lResult As Long
> lngSize = 255
> If RegOpenKey(RegistryRoot, RegistryHive, hKey) Then
> Err.Raise 1000, "fncRegistryRead", "Key Not Found: " &
RegistryRoot
> & "\" & RegistryHive
> Exit Function
> End If
> lResult = RegQueryValueEx(hKey, RegistryKey, 0, lngType, ByVal strkey,
> lngSize)
> If lResult = ERROR_SUCCESS Then
> If lngType = REG_SZ Then
> If lngSize > 0 Then lngSize = lngSize - 1
> fncRegistryRead = Left$(strkey, lngSize)
> End If
> End If
> Exit Function
> ErrorHandle:
> 'do my stuff that needs more code than you want to see.
> End Function