but how do i list them all out in memo1 ? there should be a code t odo so and it shouldn't be that long i think....
Main Topics
Browse All Topicshow can i list out all the sub-keys for HKLM onto a memo ? just the subkeys will do, not need for the values.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here is something I did for Project JEDI which orginally did HKCU, I changed it to HKLM. Simple requires a TMemo and a CommandButton. Also note it indents the branches.
Hope this of some use for solving your problem
Kevin
uses registry ;
...
procedure TEnumuateRegBranch.cmdStar
var
indent: Integer ;
iMatches: 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]) ;
try
if CompareStr('CurrentVersion
Inc(iMatches) ;
except
end ;
if OpenKey( l[n], false ) then
begin
EnumAllKeys( CurrentKey ) ;
CloseKey ;
end ;
end ;
finally
l.Free
end;
finally
Free ;
end;
Dec(indent, 2) ;
end;
begin
iMatches := 0 ;
{ Searches Key and Values for "CurrentVersion" while traversing. }
Memo1.Clear ;
//Memo1.lines.add('Keys under HKEY_CURRENT_USER') ;
Memo1.lines.add('Keys under HKEY_LOCAL_MACHINE') ;
indent := 0;
cmdStart.Enabled := False ;
cmdClose.Enabled := False ;
try
cursor := crHourGlass ;
Memo1.Lines.BeginUpdate ;
//EnumAllKeys( HKEY_CURRENT_USER );
EnumAllKeys( HKEY_LOCAL_MACHINE );
iRanIt := True ;
finally
Memo1.Lines.EndUpdate ;
Cursor := crDefault ;
cmdStart.Enabled := True ;
cmdClose.Enabled := True ;
end ;
if iMatches >0 then
ShowMessage('Found ' + IntToStr(iMatches) + ' of "CurrentVersion"')
else
ShowMessage('Did not find CurrentVersion') ;
end;
It does work!
Remove any references to 'iRanIt', it served a purpose outside of what we are doing here.
Here it is again, I removed references to the Command button and the 'iRanIt'. Ran it in a new project and functioned perfectly.
This is fairly simple recursive code. If you need any explanations of the code let me know. Always help to assist.
procedure TForm1.ReadBranchs;
var
indent: Integer ;
procedure EnumAllKeys( hkey: THandle ) ;
var
l: TStringList ;
n: Integer ;
begin
Inc(indent, 2) ;
Application.ProcessMessage
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_LOCAL_MACHINE') ;
indent := 0;
try
cursor := crHourGlass ;
Memo1.Lines.BeginUpdate ;
EnumAllKeys( HKEY_LOCAL_MACHINE );
finally
Memo1.Lines.EndUpdate ;
Cursor := crDefault ;
end ;
end;
procedure TForm1.Button1Click(Sender
begin
ReadBranchs ;
end;
tyfing:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
Business Accounts
Answer for Membership
by: VGRPosted on 2002-12-01 at 23:22:08ID: 7519025
use the standard TRegistry unit's interface, everything you need is in there.
CHINE; ) lSet\Contr ol\Compute rName\Comp uterName', False) tring('Com puterName' )
you 'll just need a "for" or "while" loop, and voilà.
FYI, this is a standard use of the Registry :
Function GetComputerName : String;
var reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MA
If reg.OpenKey('SYSTEM',False
then If reg.OpenKey('CurrentContro
Then GetComputerName:=reg.ReadS
Else GetComputerName:='(non trouvé)'
Else GetComputerName:='(non trouvé)';
reg.Free;
end;
And here are the functions/methods you'll need :
TRegistry.HasSubKeys() : Boolean
or
TRegistry.GetKeyNames :
procedure GetKeyNames(Strings: TStrings);
Description
Call GetKeyNames to determine the names of all subkeys belonging to the current key. Determining the names of subkeys is useful in an application that iterates through a set of keys.
Strings is a variable of type TStrings into which to return the list of subkey names.
(Delphi 4 help, got when pushing F1 on the word "TRegistry"...)