Компоненты TTreeView и TListView
TreeViewl.Items.Clear;
Reg.RootKey: = HKEY_LOCAL_MACHINE;
Root: = TreeViewl.Items.Add(nil,'HKEY_LOCAL_MACHINE');
TreeViewl.Items.AddChildtroot,'');
end;
procedure TForml.FormDestroy(Sender: TObject);
begin
Reg.Free;
end;
function TForml.GetFullNodeName(Node: TTreeNode):string;
var CurNode: TTreeNode;
begin
Result: = ''; CurNode: = Node;
while CurNode.Parentonil do
begin
Result: = '\'+CurNode.Text + Result;
CurNode: = CurNode.Parent;
end;
end;
procedure TForml.TreeViewlChange(Sender: TObject; Node: TTreeNode);
var s: string;
Keylnfo: TRegKeylnfo;
ValueNames: TStringList;
i: Integer;
DataType: TRegDataType;
begin
ListViewl.Items.Clear;
s: = GetFullNodeName(Node);
if not Reg.OpenKeyReadOnly(s) then Exit;
Reg.GetKeylnfo(Keylnfo);
if Keylnfo.NumValues<=0 then Exit;
ValueNames: = TStringList.Create;
Reg.GetValueNames(ValueNames);
for i: = 0 to ValueNames.Count-1 do
with ListViewl.Items.Add do
begin
Caption: = ValueNames[i];
DataType: = Reg.GetDataType(ValueNames[i]);
Case DataType of
rdString: s: = Reg.ReadString(ValueNames[i]);
rdlnteger: s: = '0x'+IntToHex(Reg.Readlnteger(ValueNames[i]),8);
rdBinary: s: = 'Binary';
else s: = '???';
end;
Subltems.Add(s);
Imagelndex: = 1;
end;
ValueNames.Free;
end;
procedure TForml.ShowSubKeys(ParentNode: TTreeNode;depth: Integer);
var ParentKey: string;
KeyNames: TStringList;
KeyInfo: TRegKeylnfo;
CurNode: TTreeNode; i: Integer;
begin
Cursor: = crHourglass;
TreeViewl.Items.BeginUpdate;
ParentKey: = GetFullNodeName(ParentNode);
if ParentKeyO1' then
Reg.OpenKeyReadOnly(ParentKey)
else
Reg.OpenKeyReadOnly('\');
Reg.GetKeylnfo(Keylnfo);
if KeyInfo.NumSubKeys<=0 then Exit;
KeyNames: = TStringList.Create;
Reg.GetKeyNames(KeyNames);
While ParentNode.GetFirstChildonil do ParentNode.GetFirstChild.Delete;
if (KeyNames.Count>0) then for i: = 0 to KeyNames.Count-1 do
begin
Reg.OpenKeyReadOnly(ParentKey+'\'-t-KeyNames[ i ]);
Reg.GetKeylnfo(Keylnfo);
CurNode: = TreeViewl.Items.AddChild(ParentNode,KeyNames[i];
if KeyInfo.NumSubKeys>0 then
begin
TreeViewl.Items.AddChild(CurNode, '');
end;
end;
KeyNames.Free;
TreeViewl.Items.EndUpdate;
Cursor: = crDefault;
end;
procedure TForml.TreeViewlExpanded(Sender: TObject; Node: TTreeNode);
begin
ShowSubKeys(Node,1);
end;
procedure TForml.TreeViewlGetlmagelndex(Sender: TObject; Node: TTreeNode);
begin
with Node do
begin
if Expanded then Imagelndex: = 2
else Imagelndex: = 3;
end;
end;
end.