I think this question has been posted before, but I don't remember this anymore. So what should I do to make the program write all the entries in one registry key to a listbox/combobox?
Printable View
I think this question has been posted before, but I don't remember this anymore. So what should I do to make the program write all the entries in one registry key to a listbox/combobox?
There was alot of stuff about the Registry posted in the thread here. The answer to your question, listing all the Entries, is in the post by me (SonGouki). The code I posted there allows you to do multiple things including any combination of listing all of the Entries in a Key and listing all Sub-Keys of a Key (can go also go through all Sub-Keys of a Sub-Key, using recursion).
If you need me to explain it at all just ask.
I tried to enumerate the COMPLETE registry but all I got was a stack overflow :(
Well, naturally, you can't enumerate the entire registry in a single ListBox, it can only hold 32767 entries. With my code you can only enumerate, at most, one top-level Key at a time, so instead place the results into a FlexGrid or several ListBoxes (or even just into an array).
I didn't use a listbox but an array
I ran a recursive function... this caused the stack overflow
Hmmmmm...
It sounds like a problem with your code. An array can hold
up to 2,147,483,647 elements, so I don't think you should
have any problems there. Post your code so I can take a
look at it and see if I can spot your problem.
The array isn't the problem. It's the function calls that cause the stack overflow
Code:Public Sub RegistrySearch(hkey As Long, Path As String)
Dim allkeys As Variant
Dim i&, x&
Dim allvalues As Variant
DoEvents
If Right(Path, 1) = "\" Then Path = Left(Path, Len(Path) - 1)
allkeys = GetAllKeys(hkey, Path)
If IsArray(allkeys) = True Then
For i = LBound(allkeys) To UBound(allkeys)
RegKeys(UBound(RegKeys)).Path = Path & "\" & allkeys(i)
ReDim RegKeys(UBound(RegKeys)).Values(0)
allvalues = GetAllValues(hkey, Path & "\" & allkeys(i))
For x = LBound(allvalues) To UBound(allvalues)
RegKeys(UBound(RegKeys)).Values(UBound(RegKeys(UBound(RegKeys)).Values)).Name = allvalues(x, 0)
RegKeys(UBound(RegKeys)).Values(UBound(RegKeys(UBound(RegKeys)).Values)).Setting = allvalues(x, 1)
ReDim Preserve RegKeys(UBound(RegKeys)).Values(UBound(RegKeys(UBound(RegKeys)).Values) + 1)
Next x
' Form1.Caption = Path & allkeys(i)
ReDim Preserve RegKeys(UBound(RegKeys) + 1)
RegistrySearch hkey, Path & "\" & allkeys(i)
DoEvents
Next i
End If
End Sub