Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to loop through the keys in the registry Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Sep-02
Category
Win API
Language
Delphi 2.x
Views
106
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert 

I am making a program for editing the registry. It will basically be the same as 
regedit, but with some added features. What I want to know is how should I go about 
reading the registry into my TreeView and ListView components and how do I specify 
which icons to use in the tree view? I know you can load files into a list view 
using the FindFirst, FindNext and FindClose, but how do you loop through the keys 
in the registry?

Answer:

Enumerating registry keys:


1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     indent: Integer;
4   
5     procedure EnumAllKeys(hkey: THandle);
6     var
7       l: TStringList;
8       n: Integer;
9     begin
10      Inc(indent, 2);
11      with TRegistry.Create do
12      try
13        RootKey := hkey;
14        OpenKey(EmptyStr, false);
15        l := TStringLIst.Create;
16        try
17          GetKeynames(l);
18          CloseKey;
19          for n := 0 to l.Count - 1 do
20          begin
21            memo1.lines.add(StringOfChar(' ', indent) + l[n]);
22            if OpenKey(l[n], false) then
23            begin
24              EnumAllKeys(CurrentKey);
25              CloseKey;
26            end;
27          end;
28        finally
29          l.Free
30        end;
31      finally
32        Free;
33      end;
34      Dec(indent, 2);
35    end;
36  begin
37    memo1.Clear;
38    memo1.lines.add('Keys under HKEY_CURRENT_USER');
39    indent := 0;
40    EnumAllKEys(HKEY_CURRENT_USER);
41  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC