• 使用 TRegistry 类[1]: 显示各主键下的项


    使用 TRegistry 类[1]: 显示各主键下的项

    {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

  • 相关阅读:
    iOS- 优化与封装 APP音效的播放
    iOS- iPhone App 如何运营?
    iOS- 封装单例宏
    iOS- 详解文本属性Attributes
    iOS- 如何将应用集成发短信、发邮件、打电话
    iOS- <项目笔记> UIApplication常见属性与方法总结
    iOS- <项目笔记>iOS6 & iOS7屏幕图片适配
    iOS- <项目笔记>项目配置常见文件
    iOS- <项目笔记>UI控件常见属性总结
    iOS- UIPickerView餐厅点餐系统
  • 原文地址:https://www.cnblogs.com/karkash/p/3436638.html
Copyright © 2020-2023  润新知