Autor Beitrag
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mi 02.03.05 17:27 
Ungültie ZeigeoperationHallo, ich will was aus der Registry auslesen und dann in eine Treeview übergeben, hab den Quellcode aus nem Delphi-Buch abgetippt. nur bekomme ich die im Titel genannte Fehlermeldung. An was kann es liegen?

Source:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
var
  Form1: TForm1;
  i:integer;
  reg:tregistry;
  list:tstringlist;
implementation

{$R *.dfm}

procedure GetAllKeys(root:HKEY;Key:string;node:TTreenode);

begin
   reg:=Tregistry.Create();
   reg.RootKey:=root;
   reg.OpenKey(Key,false);
   if reg.HasSubKeys then begin

   list:=TStringlist.Create;
   reg.GetKeyNames(list);
   For i := 0 to list.Count-1 do begin
      if list[i]<>'' then begin
       GetAllKeys(root, Key+'\'+list[i],Form1.TreeView1.Items.AddChild(node,list[i]));
      end;
   end;

   end;
   reg.free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Treeview1.Items.BeginUpdate;
GetAllKeys(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',Treeview1.Items.Add(nil,'HKEY_LOCAL_MACHINE'));
Treeview1.Items.EndUpdate;
end;

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Do 03.03.05 11:47 
1. Das Object list wird nie wieder frei gegeben (list.Free).
2. Es müsste m.E. bei rekursivem Aufruf nicht global sondern lokal in der prozedur deklariert und instanziert werden.

Aber schick doch mal die Fehlermeldung, die ich im Titel nicht gefunden habe !


Chris

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Fr 04.03.05 18:39 
Ich hab den titel geändert: Ungültige Zeigeopertaion

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?