unit test;
interface
uses
SysUtils, Classes, Windows;
type
TRootKey = LongWord;
TTest =
class(TComponent)
private
FRootkey: TRootKey;
public
constructor Create(AOwner: TComponent);
override;
published
property RootKey: TRootKey
read FRootKey
write FRootKey
default HKEY_CURRENT_USER;
end;
const
RootKeys:
array[0..6]
of TIdentMapEntry = (
(Value: HKEY_CLASSES_ROOT - $80000000;
Name: '
HLEY_CLASSES_ROOT'),
(Value: HKEY_CURRENT_USER - $80000000;
Name: '
HKEY_CURRENT_USER'),
(Value: HKEY_LOCAL_MACHINE - $80000000;
Name: '
HKEY_LOCAL_MACHINE'),
(Value: HKEY_USERS - $80000000;
Name: '
HKEY_USERS'),
(Value: HKEY_PERFORMANCE_DATA - $80000000;
Name: '
HKEY_PERFORMANCE_DATA'),
(Value: HKEY_CURRENT_CONFIG - $80000000;
Name: '
HKEY_CURRENT_CONFIG'),
(Value: HKEY_DYN_DATA - $80000000;
Name: '
HKEY_DYN_DATA')
);
function IdentToRootKey(
const Ident:
string;
var RootKey: Longint): Boolean;
function RootKeyToIdent(RootKey: Longint;
var Ident:
string): Boolean;
procedure Register;
implementation
constructor TTest.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
RootKey := HKEY_CURRENT_USER;
end;
procedure Register;
begin
RegisterComponents('
Beispiele', [TTest]);
end;
function RootKeyToIdent(RootKey: Longint;
var Ident:
string): Boolean;
begin
Result := IntToIdent(RootKey, Ident, RootKeys);
end;
function IdentToRootKey(
const Ident:
string;
var RootKey: Longint): Boolean;
begin
Result := IdentToInt(Ident, RootKey, RootKeys);
end;
initialization
RegisterIntegerConsts(TypeInfo(TRootKey), IdentToRootKey, RootKeyToIdent);
end.