zoukankan      html  css  js  c++  java
  • 使用 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

  • 相关阅读:
    <html>
    poj 2676 Sudoku
    百亿互金平台救火故事
    Retrofit三步理解之中的一个 ------------------ Retrofit的简单使用总结
    精简版—愤慨的小鸟
    POJ 1095 Trees Made to Order
    Android Studio 错误: 非法字符: &#39;ufeff&#39; 解决方式|错误: 须要class, interface或enum
    使用CodePush实时更新 React Native 和 Cordova 应用
    获取url地址参数
    利用jQuery 通用文件导出前端实现,MVC文件导出
  • 原文地址:https://www.cnblogs.com/karkash/p/3436638.html
Copyright © 2011-2022 走看看