Author: Lou Adler How do I iterate through the entries of HKLM and look for a particular string? Answer: Searching for a substring in a registry tree: 1 2 procedure SearchRegistry(aRoot: HKEY; searchfor: string; resultlist: TStrings); 3 4 procedure EnumKey(const keyname: string); 5 6 function VName(const valuename: string): string; 7 begin 8 if Length(valuename) = 0 then 9 Result := '@' 10 else 11 Result := valuename; 12 end; 13 14 var 15 reg: TRegistry; 16 temp: TStringList; 17 S: string; 18 i: Integer; 19 begin 20 reg := TRegistry.Create; 21 try 22 reg.Rootkey := aRoot; 23 if reg.OpenKeyReadOnly(keyname) then 24 begin 25 {Enumerate the values} 26 temp := TStringList.Create; 27 try 28 reg.GetValueNames(temp); 29 for i := 0 to temp.Count - 1 do 30 begin 31 if reg.GetDatatype(temp[i]) = rdString then 32 begin 33 S := reg.ReadString(temp[i]); 34 if Length(S) > 0 then 35 begin 36 if Pos(searchfor, AnsiUpperCase(S)) > 0 then 37 resultlist.add(Format('%s %s ="%s"', [keyname, Vname(temp[i]), 38 S])); 39 end; 40 end; 41 end; 42 temp.Clear; 43 {Enumerate the subkeys} 44 if reg.HasSubKeys then 45 begin 46 reg.GetKeyNames(temp); 47 for i := 0 to temp.count - 1 do 48 EnumKey(keyname + '\' + temp[i]); 49 end; 50 finally 51 temp.free; 52 end; 53 end; 54 reg.CloseKey; 55 finally 56 reg.free; 57 end; 58 end; 59 60 begin 61 searchfor := AnsiUpperCase(searchfor); 62 EnumKey(EmptyStr); 63 end; 64 65 //Used like this: 66 67 procedure TForm1.Button1Click(Sender: TObject); 68 begin 69 Memo1.clear; 70 Screen.Cursor := crHourglass; 71 try 72 SearchRegistry(HKEY_CLASSES_ROOT, 'internet', memo1.lines); 73 finally 74 Screen.Cursor := crDefault; 75 end; 76 end;