Enumerating Registry Values In Delphi


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;

Featured Posts
Recent Posts
Archive
Search By Tags