program Project23;
{$APPTYPE CONSOLE}
uses System.SysUtils, System.Win.Registry, System.Classes,
Winapi.Windows;
procedure registryAccess();
const
registryPath:
String = '
Software\Günthersoft\meinProgramm';
registrySubPath:
String = '
mySection';
var
Reg : TRegistry;
valueNames: TStrings;
valueName:
String;
begin
Reg := TRegistry.Create(KEY_READ);
Reg.RootKey := HKEY_CURRENT_USER;
try
OutputDebugString(PChar(
'
Key Exists ist ' +
BooltoStr(Reg.KeyExists(registryPath), true)
));
if Reg.KeyExists(registryPath)
then begin
Reg.OpenKey(registryPath, false);
OutputDebugString(PChar(
'
Key Exists ist ' +
BooltoStr(Reg.KeyExists(registrySubPath), true)
));
if Reg.KeyExists(registrySubPath)
then begin
Reg.OpenKey(registrySubPath, false);
valueNames := TStringList.Create();
try
Reg.GetValueNames(valueNames);
for valueName
in valueNames
do WriteLn(valueName);
finally
valueNames.Destroy();
end;
end;
end;
Reg.CloseKey();
finally
Reg.Destroy();
end;
end;
begin
try
registryAccess();
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
WriteLn(slineBreak,'
Ende'); readln;
end.