How to get the sub-key name (eg. Stk Group\ BISCUIT) from registry?
+4
A:
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.
Michał Niklas
2010-06-21 05:10:30
+4
A:
use Tregistry
's GetKeyNames
http://docwiki.embarcadero.com/VCL/en/Registry.TRegistry.GetKeyNames
glob
2010-06-21 05:11:07
+2
A:
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;
XBasic3000
2010-06-21 06:22:15
Why are you using the API's when there is a perfectly good and easier to use wrapper class for them (TRegistry)?
Marjan Venema
2010-06-21 08:08:09
@Marjan Venema, only if you want your executable size as small as possible
DonnVall
2010-10-14 00:14:41
+1 DonnVall. for me, i use the most native/simpliest way to reduce size.
XBasic3000
2010-10-14 01:29:24
@DonnVall, @XBasic3000: oh, ok, if size is important I guess I'd do the same. As I am not faced with such constraints I tend to go for understandability, maintainability, ease of use, expressiveness, that sort of thing :-)
Marjan Venema
2010-10-14 07:28:33
@Marjan: Lol! I should've said, "On rare occassion when size does matter...". So far I only met two or three projects that specifically ask that requirement (small size). Other than that, of course I will stick with TRegistry.
DonnVall
2010-10-14 10:23:28