使用 TRegistry 类[1]: 显示各主键下的项
使用 TRegistry 类[1]: 显示各主键下的项
涂孟超 发表于3年前
使用 TRegistry 类[1]: 显示各主键下的项
  • 发表于 3年前
  • 阅读 3
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】如何购买服务器最划算?>>>   

{XP 注册表中的主键}
HKEY_CLASSES_ROOT    {文件类型信息} 
HKEY_CURRENT_USER    {当前用户信息}
HKEY_LOCAL_MACHINE   {软硬件信息} 
HKEY_USERS           {所有用户信息} 
HKEY_CURRENT_CONFIG  {当前配置信息}

{Delphi 定义的常量}
HKEY_CLASSES_ROOT     = DWORD($80000000);
HKEY_CURRENT_USER     = DWORD($80000001);
HKEY_LOCAL_MACHINE    = DWORD($80000002);
HKEY_USERS            = DWORD($80000003);
HKEY_PERFORMANCE_DATA = DWORD($80000004);
HKEY_CURRENT_CONFIG   = DWORD($80000005);
HKEY_DYN_DATA         = DWORD($80000006);

 
 
 
 
 

 

 

  
本例效果图:



代码文件:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    RadioGroup1: TRadioGroup;
    procedure FormCreate(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Registry;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Align := alLeft;
  RadioGroup1.Items.CommaText := 'HKEY-CLASSES-ROOT,' +
                                 'HKEY-CURRENT-USER,' +
                                 'HKEY-LOCAL-MACHINE,' +
                                 'HKEY-USERS,' +
                                 'HKEY-CURRENT-CONFIG';
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;

  case RadioGroup1.ItemIndex of
    0: reg.RootKey := HKEY_CLASSES_ROOT;
    1: reg.RootKey := HKEY_CURRENT_USER; {这是 RootKey 的默认值}
    2: reg.RootKey := HKEY_LOCAL_MACHINE;
    3: reg.RootKey := HKEY_USERS;
    4: reg.RootKey := HKEY_CURRENT_CONFIG;
  end;

  reg.OpenKey('', False);
  reg.GetKeyNames(ListBox1.Items);
  reg.CloseKey;
  reg.Free;
end;

end.

 
 
 
 
 

 

 

  
窗体文件:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 176
  ClientWidth = 325
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object ListBox1: TListBox
    Left = 0
    Top = 8
    Width = 153
    Height = 134
    ItemHeight = 13
    TabOrder = 0
  end
  object RadioGroup1: TRadioGroup
    Left = 159
    Top = 8
    Width = 158
    Height = 160
    Caption = 'RadioGroup1'
    TabOrder = 1
    OnClick = RadioGroup1Click
  end
end

 
 
 
 
 

 

 

  
共有 人打赏支持
粉丝 12
博文 2004
码字总数 14107
×
涂孟超
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: