whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

19 Visitors Online


 
...enumerate registry keys?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (16):  
     


{
  This example demonstrates how to enumerate all registry keys from
  a certain key (here: HKEY_CURRENT_USER)
}

{
  Dieses Beispiel listet alle Einträge eines bestimmten Schlüssels
  in der Registrierung auf. (hier: HKEY_CURRENT_USER)
}



uses
  
Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  
indent: Integer;
  
  procedure EnumAllKeys(hkey: THandle);
  var
    
l: TStringList;
    n: Integer;
  begin
    
Inc(indent, 2);
    with TRegistry.Create do
      try
        
RootKey := hkey;
        OpenKey(EmptyStr, False);
        l := TStringList.Create;
        try
          
GetKeynames(l);
          CloseKey;
          for n := 0 to l.Count - 1 do
          begin
            
memo1.Lines.Add(StringOfChar(' ', indent) + l[n]);
            if OpenKey(l[n], False) then
            begin
              
EnumAllKeys(CurrentKey);
              CloseKey;
            end;
          end;
        finally
          
l.Free
        end;
      finally
        
Free;
      end;
    Dec(indent, 2);
  end;

begin
  
Memo1.Clear;
  Memo1.Lines.Add('Keys under HKEY_CURRENT_USER');
  indent := 0;
  Memo1.Lines.BeginUpdate;
  try
    
EnumAllKEys(HKEY_CURRENT_USER);
  finally
    
Memo1.Lines.EndUpdate;
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners