Results 1 to 3 of 3

Thread: Registry Recursion

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Phoenix
    Posts
    150

    Exclamation Registry Recursion

    I have been trying to get this for days and just cannot come up with anything:

    I want to enter a registry key and get all subfolders under it with each subfolder of the subfolder and subfolder of that subfolder, etc. I do not want just one level, but every level that it can be broken down into.

    Has anyone ever done this or know how to do it? I would like to add the keys to a treeview kinda like the Registry Editor. The first one would be HKEY_LOCAL or whatever and list every key in it with the plus signs.

    Thanks in advance.
    Last edited by matt_man22; May 30th, 2001 at 03:37 PM.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    TreeViews are a pain in the ass... but once you have it down... it's pretty easy.... I do my tree setup like so:

    logic of the tree structure
    root = A0 top of the tree
    1st child# = B# next branch
    2nd child# = C# next branch
    etc...
    ::example::
    A0
    +..B1
    | +..C1
    |
    +..B2
    +..C2
    +..C3


    Code:
    Public Type IndentTable
        indent As Long       '' value should be >= 1  values will determine aplha character
        disp   As String     '' name to be displayed on the treeview
    End Type
    
    Public Sub SetupTree(ByRef tv As TreeView, ByRef d() As IndentTable, ByVal strTitle As String)
        
        Dim nodX         As Node    '' new node for the tree structure.
        Dim ChildStr     As String  '' current child ASCII tree index. EX: B
        Dim Child        As String  '' current child ASCII-numeric tree index Code. EX: B1
        Dim ChildCount   As Long    '' current count on the specific child.
        Dim levelCnt(26) As Long    '' record of current child values.
        Dim i            As Long    '' general counter
        Dim Subset       As String  '' defines what subset the new label should go under.
        Dim SubsetStr    As String
        Dim SubsetCount  As Long    '' number of subsets
        
        
        '' make sure the tree has no existing nodes
        Call tv.Nodes.Clear
        
        '' make sure the tree is visible
        tv.Visible = True
        
        '' setup inital root name for the tree structure
        '' this should be the only A# level
        Set nodX = tv.Nodes.Add(, , "A0", strTitle)
        
        tv.Style = tvwTreelinesPlusMinusText   '' Style 6
        tv.BorderStyle = vbFixedSingle
        
        '' loop through all elements in the array and add the correct level to the tree
        For i = LBound(d) To UBound(d)
            
            ChildStr = Chr$(65 + d(i).indent)
            
            levelCnt(Asc(ChildStr) - 64) = levelCnt(Asc(ChildStr) - 64) + 1
            ChildCount = levelCnt(Asc(ChildStr) - 64)
            
            Child = ChildStr & ChildCount
            
            SubsetStr = Chr$(64 + d(i).indent)
            SubsetCount = levelCnt(Asc(SubsetStr) - 64)
            Subset = SubsetStr & SubsetCount
            
            '' add the node to the treeview
            Set nodX = tv.Nodes.Add(Subset, tvwChild, Child, d(i).disp)
            
        Next i
        
    End Sub
    hopefully this will give you some ideas. With this code you can only go to B->Z levels deep.
    -Shickadance

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Phoenix
    Posts
    150
    I'm pretty good with the treeview control. The problem is that I need to get the registry keys. How would you get the keys into the treeview control? I can't figure out how to get the first key, get all its sub-keys, get the sub-keys of the sub-keys, and then come back and do that for each additional key. I think you see my problem . This is what I really need help on.

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