We help IT Professionals succeed at work.

reading registry

kevinward66
kevinward66 asked
on
Medium Priority
167 Views
Last Modified: 2010-04-06
how can i read a FULL folder out of the reqistry into a memo in code

ie

i want to read the last 25 urls typed into a memo and don't want to go through the process of reading one at a time!!!
Comment
Watch Question

Commented:
hmmm, off hand I'd think you'd do something like (warning, on-the-fly-pseudo-code ahead):

var
 reg : TRegistry;
 ix : integer;
 values : TStringList;
begin
 reg := TRegistry.create(self);
//set reg to root key, & open desired key here
 values := TStringList.create;
 reg.getValueName(values);

 for ix := 0 to values.count-1 do
  memo1.lines.add(reg.readString(values[ix]));

 reg.close;
 reg.free;
 values.free;
end;


GL
Mike
Software Developer
CERTIFIED EXPERT
Commented:
Hello
 
  This example will read all the strings in ..\Run, and their values

uses Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  Reg: TRegistry;
  Val:TStringList;
  I:Integer;
begin
  Reg:=TRegistry.Create;
  Val:=TStringList.Create;
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  Reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',False);
  Reg.GetValueNames(Val);
  for I := 0 to Val.Count -1 do
  Memo1.Lines.Add (Val.Strings[I] + ' : ' + Reg.ReadString(Val.Strings[I]));
  Val.Free;
  Reg.Free;
end ;

Author

Commented:
thanks this is EXACTALLY what i wanted!!!

once again thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.