Marco Web Center |
Home: Code Repository: Mastering Delphi 5Project REGVIEW
Project StructureREGVIEW.DPRprogram Regview; uses Forms, regform in 'Regform.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. REGFORM.PASunit regform; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Registry; type TForm1 = class(TForm) ListSub: TListBox; ListValues: TListBox; ComboKey: TComboBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; ComboLast: TComboBox; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ListSubClick(Sender: TObject); procedure ComboKeyChange(Sender: TObject); procedure ComboLastChange(Sender: TObject); private Reg: TRegistry; public procedure UpdateAll; end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin Reg := TRegistry.Create; Reg.OpenKey ('\', False); UpdateAll; // select the current root ComboKey.ItemIndex := 1; ComboLast.Items.Add('\'); /////// ComboLast.ItemIndex := 0; end; procedure TForm1.UpdateAll; begin Caption := Reg.CurrentPath; if Caption = '' then Caption := '[Root]'; if Reg.HasSubKeys then Reg.GetKeyNames(ListSub.Items) else ListSub.Clear; Reg.GetValueNames(ListValues.Items); end; procedure TForm1.FormDestroy(Sender: TObject); begin Reg.CloseKey; Reg.Free; end; procedure TForm1.ListSubClick(Sender: TObject); var NewKey, Path: string; nItem: Integer; begin // get the selection NewKey := ListSub.Items [ListSub.ItemIndex]; Reg.OpenKey (NewKey, False); // save the current path (eventually adding a \) // only if the it is not already listed Path := Reg.CurrentPath; if Path < '\' then Path := '\' + Path; nItem := ComboLast.Items.IndexOf (Path); if nItem < 0 then begin ComboLast.Items.Insert (0, Path); ComboLast.ItemIndex := 0; end else ComboLast.ItemIndex := nItem; UpdateAll; end; procedure TForm1.ComboKeyChange(Sender: TObject); begin case ComboKey.ItemIndex of 0: Reg.RootKey := HKEY_CLASSES_ROOT; 1: Reg.RootKey := HKEY_CURRENT_USER; 2: Reg.RootKey := HKEY_LOCAL_MACHINE; 3: Reg.RootKey := HKEY_USERS; 4: Reg.RootKey := HKEY_CURRENT_CONFIG; 5: Reg.RootKey := HKEY_DYN_DATA; end; Reg.OpenKey ('\', False); UpdateAll; ComboLast.Items.Clear; end; procedure TForm1.ComboLastChange(Sender: TObject); begin Reg.OpenKey (ComboLast.Text, False); UpdateAll; end; end. REGFORM.DFMobject Form1: TForm1 Left = 123 Top = 109 Width = 430 Height = 331 Caption = 'RegView' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OnCreate = FormCreate OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 8 Top = 72 Width = 45 Height = 13 Caption = 'Sub Keys' end object Label2: TLabel Left = 216 Top = 72 Width = 53 Height = 13 Caption = 'Key Values' end object Label3: TLabel Left = 8 Top = 11 Width = 23 Height = 13 Caption = 'Keys' end object Label4: TLabel Left = 8 Top = 44 Width = 46 Height = 13 Caption = 'Last Keys' end object ListSub: TListBox Left = 8 Top = 88 Width = 201 Height = 209 ItemHeight = 13 TabOrder = 0 OnClick = ListSubClick end object ListValues: TListBox Left = 216 Top = 88 Width = 201 Height = 209 ItemHeight = 13 TabOrder = 1 end object ComboKey: TComboBox Left = 64 Top = 8 Width = 193 Height = 21 Style = csDropDownList ItemHeight = 13 Items.Strings = ( 'HKEY_CLASSES_ROOT' 'HKEY_CURRENT_USER' 'HKEY_LOCAL_MACHINE' 'HKEY_USERS' 'HKEY_CURRENT_CONFIG' 'HKEY_DYN_DATA') TabOrder = 2 OnChange = ComboKeyChange end object ComboLast: TComboBox Left = 64 Top = 40 Width = 353 Height = 21 Style = csDropDownList ItemHeight = 13 Sorted = True TabOrder = 3 OnChange = ComboLastChange end end
|
||
© Copyright Marco Cantù, 1995-2020, All rights reserved |