Results 1 to 7 of 7

Thread: Listing Registry Values

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    29

    Question

    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?

  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    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.
    Dan PM
    Analyst Programmer

    VB6 SP3 (also VB4 16-bit sometimes )

  3. #3
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161
    I tried to enumerate the COMPLETE registry but all I got was a stack overflow
    Razzle
    ICQ#: 31429438
    What is the difference between a raven?
    -The legs. The length is equal, especially the right one.

  4. #4
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    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).
    Dan PM
    Analyst Programmer

    VB6 SP3 (also VB4 16-bit sometimes )

  5. #5
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161
    I didn't use a listbox but an array
    I ran a recursive function... this caused the stack overflow
    Razzle
    ICQ#: 31429438
    What is the difference between a raven?
    -The legs. The length is equal, especially the right one.

  6. #6
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Question

    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.
    Dan PM
    Analyst Programmer

    VB6 SP3 (also VB4 16-bit sometimes )

  7. #7
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161
    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
    Razzle
    ICQ#: 31429438
    What is the difference between a raven?
    -The legs. The length is equal, especially the right one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width