Enumerating Registry Values In Delphi

Enumerating Registry Values In Delphi

June 14, 2018

 

 

Example: 

uses 
  Registry;

 

procedure GetKeyList(Root: HKEY; Key: String; List: TStrings); 

procedure GetList(Key: String); 
var 
  R: TRegistry; 
  i: Integer; 
  Keys, Values: TStrings; 
begin 
  R := TRegistry.Create; 
  try 
    R.RootKey := Root; 
    if not R.OpenKeyReadOnly(Key) then 
      RaiseLastWin32Error; 
    try 
      Keys := TStringList.Create; 
      try 
        R.GetKeyNames(Keys); 
        for i := 0 to Keys.Count - 1 do 
          GetList(Key + Keys[i] + '\'); 
      finally 
        Keys.Free; 
      end; 
      Values := TStringList.Create; 
      try 
        R.GetValueNames(Values); 
        for i := 0 to Values.Count - 1 do

// if FileExists(Values[i]) = false then //Find Invalid Keys
          List.Add(Key + Values[i]); 
      finally 
        Values.Free; 
      end; 
    finally 
      R.CloseKey; 
    end; 
  finally 
    R.Free; 
  end; 
end; 

begin 
  GetList(Key + '\'); 
end; 

 

 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
  GetKeyList(HKEY_LOCAL_MACHINE, 
'Software\Microsoft\Windows\CurrentVersion', Memo1.Lines);


end; 

 

 

 

 

 

 

 

 

Share on Facebook
Share on Twitter
Please reload

Featured Posts

Process list In Delphi (Source Code Attached)

August 28, 2019

1/10
Please reload

Recent Posts