Autor Beitrag
florida
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

Windows 7 Home Premium, Windows XP Professional, Windows 2000
Delphi 2010 Architect
BeitragVerfasst: So 29.03.09 08:17 
Wie kann man eigentlich alle Ordner der Registry in einen TreeView auflisten?
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 29.03.09 15:48 
Nun, du brauchst dazu eine Variable vom Typ TRegistry. Bei ihr setzt du den root-key auf einen der root keys :) Nun kannst du mit der Methode OpenKeyReadOnly einen Schlüssel öffnen und dann mit GetKeyNames seine Unterschlüssel auflisten. Wenn du die Unterschlüssel des aktuellen Root-Keys haben willst, musst du OpenKeyReadOnly nur einen leeren String übergeben.
Am besten schreibst du dir eine rekursive Prozedur die immer für einen gefundenen Unterschlüssel aufgerufen wird, die das einfügen in einen TreeView durchführt.
Hier mal eine kleine Beispielprozedur, mit der du den Inhalt von HKEY_CURRENT_USER in eine Listbox bekommst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  reg : TRegistry;
  sl : TStringList;
begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_CURRENT_USER;
  sl := TStringList.Create;
  if not reg.OpenKeyReadOnly('') then //öffnen des RootKeys
    showmessage('fehler'); //Öffnen fehlgeschlagen (vllt keine Berechtigung?)
  reg.GetKeyNames(sl);
  Listbox1.Items.AddStrings(sl);
  reg.free;
  sl.free;

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
florida Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

Windows 7 Home Premium, Windows XP Professional, Windows 2000
Delphi 2010 Architect
BeitragVerfasst: Di 31.03.09 15:41 
Danke! Hat geholfen! :D