⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajregistry.pas

📁 是不是天天看見MS的注冊表看膩了
💻 PAS
字号:


unit ajRegistry;



interface

uses
  Windows;

{..................................................................................................}

const
  cNumRegHKEYKeys = 5; // Number of keys supported.
  cRegHKEYLookUp  : array[1..cNumRegHKEYKeys] of record
    Description : string;
    Value       : HKEY;
  end = ((Description : 'HKEY_CLASSES_ROOT'; Value : HKEY_CLASSES_ROOT),
         (Description : 'HKEY_CURRENT_USER'; Value : HKEY_CURRENT_USER),
         (Description : 'HKEY_LOCAL_MACHINE'; Value : HKEY_LOCAL_MACHINE),
         (Description : 'HKEY_USERS';  Value : HKEY_USERS),
         (Description : 'HKEY_CURRENT_CONFIG'; Value : HKEY_CURRENT_CONFIG));

{..................................................................................................}

function RegNumSubKeys  (HKEYValue : HKEY; SubKey : string) : integer;
function HKEYTextToHKEY (HKEYText : string) : HKEY;

implementation

uses
  SysUtils;

{--------------------------------------------------------------------------------------------------}
{                                       Registry Functions                                         }
{--------------------------------------------------------------------------------------------------}

function HKEYTextToHKEY(HKEYText : string) : HKEY;
var
  lp1 : integer;
begin
  lp1 := 0;
  repeat
    inc(lp1);
  until (cRegHKEYLookUp[lp1].Description = HKEYText) or (lp1 = cNumRegHKEYKeys);

  if (cRegHKEYLookUp[lp1].Description = HKEYText) then
    Result  := cRegHKEYLookUp[lp1].Value
  else
    raise Exception.Create(HKEYText + ' - Invalid HKEY description');
end; {HKEYTextToHKEY}

{--------------------------------------------------------------------------------------------------}

function RegNumSubKeys(HKEYValue : HKEY; SubKey : string) : integer;
// Returns the number of keys.
var
  Key         : HKEY;
  NumSubKeys  : DWORD;
begin
  Result  := 0;
  if (RegOpenKeyEx(HKEYValue, PChar(SubKey), 0, KEY_QUERY_VALUE, Key) = ERROR_SUCCESS) then begin
    if (RegQueryInfoKey(Key, nil, nil, nil, @NumSubKeys, nil, nil, nil, nil, nil, nil, nil) = ERROR_SUCCESS) then
      Result  := NumSubKeys;
    RegCloseKey(Key);
  end; {if}
end; {RegNumSubKeys}

{--------------------------------------------------------------------------------------------------}
{ajRegistry}
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -