如何获得子键的名称?

时间:2010-06-21 04:38:14

标签: delphi registry delphi-7

如何从注册表中获取子密钥名称(例如Stk Group \ BISCUIT)?

3 个答案:

答案 0 :(得分:5)

您在寻找TRegistry.GetKeyNames(Strings: TStrings);

吗?

来自帮助:返回一个字符串列表,其中包含属于当前键的所有子键的名称。

答案 1 :(得分:4)

答案 2 :(得分:0)

function GetRegSubTree( MainKey : LongInt; var aList : TStringList; aKey :
string ) : Boolean;
var
  hRoot          : HKEY;
  lItem          : LongInt;
  hError         : LongInt;
  szKey,pData          : PChar;
  aString        : String;

begin
   GetRegSubTree:=false;
   if aList=Nil then exit;
{create pointers for the API}
  szKey := StrAlloc( Length( aKey ) + 1 );
  StrPCopy( szKey, aKey );
  lItem := 0;
  pData := StrAlloc( 1024 );

  hError := RegOpenKey( MainKey, szKey, hRoot );
  if hError = ERROR_SUCCESS then
  begin
     while (hError = ERROR_SUCCESS) do
     begin
        hError := RegEnumKey( hRoot, lItem, pData, 1024 );
        if (hError = ERROR_SUCCESS) then
        begin
           GetRegSubTree:=true;
           aList.Add( StrPas( pData ));
           Inc(lItem);
        end;
     end;
     RegCloseKey( hRoot );
  end;
  StrDispose( szKey );
  StrDispose( pData );
end;
相关问题