title: How to display registry in A treeView in Delphi 7
body: <p>I want to display a treeview with all the registry information in it ( i.e all the subkeys ). I have put together the following Fn to do the same. But i am getting the info of only one Key, not all. What is missing in my code ?</p>
  
  <pre><code> function TForm1.DisplayKeys(TreeNode : TTreeNode;KeyToSearch:String):String;
   var
    i: Integer;
    RootKey : Integer;
    NewTreeNode : TTreeNode;
    str : TStringList;
  
   // str2: TStringList;
   begin
     i:=0;
  
     if reg.OpenKey(KeyToSearch,False) then
     begin
     str:=nil;
     str:=TStringList.create;
     reg.GetKeyNames(str);
     //For all SubKeys
     for i:=0 to str.Count-1 do
     begin
        NewTreeNode:=TreeView1.Items.AddChild(TreeNode, Str.Strings[i]);
        if reg.HasSubKeys then
        begin
          DisplayKeys(NewTreeNode,Str.Strings[i]);
        end;
     end;
   end;
  </code></pre>
  
  <p>the call to the Function is </p>
  
  <pre><code>  procedure TForm1.FormCreate(Sender: TObject);
    begin
       reg:=nil;
      reg:=TRegistry.create;
      str2:=nil;
      str2:=TStringList.create;
     reg.RootKey:=HKEY_CURRENT_CONFIG;
     TreeView1.Items.BeginUpdate; //prevents screen repaint every time node is added
        DisplayKeys(nil,''); // call to fn here
     TreeView1.Items.EndUpdate; // Nodes now have valid indexes
   end;
  </code></pre>
  
  <p>Note that i am not getting any error, just that info is incomplete</p>