开发者

How to get the sub-key's name?

开发者 https://www.devze.com 2023-01-04 08:03 出处:网络
How开发者_StackOverflow社区 to get the sub-key name (eg. Stk Group\\ BISCUIT) from registry?Are you looking for TRegistry.GetKeyNames(Strings: TStrings);

How开发者_StackOverflow社区 to get the sub-key name (eg. Stk Group\ BISCUIT) from registry?


Are you looking for TRegistry.GetKeyNames(Strings: TStrings);

From help: Returns a string list containing the names of all subkeys belonging to the current key.


use Tregistry's GetKeyNames

http://docwiki.embarcadero.com/VCL/en/Registry.TRegistry.GetKeyNames


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号