彼のインスタンスと変数へのオフセットを使用して、クラスの厳密なプライベート クラス var値にアクセスする必要があります。
これまでにこれを試しました。このサンプルクラスを確認してください
type
TFoo=class
strict private class var Foo: Integer;
public
constructor Create;
end;
constructor TFoo.Create;
begin
inherited;
Foo:=666;
end;
//this function works only if I declare the foo var as
//strict private var Foo: Integer;
function GetFooValue(const AClass: TFoo): Integer;
begin
Result := PInteger(PByte(AClass) + 4)^
end;
ご覧のとおり、関数 GetFooValue は、foo 変数がクラス var のように宣言されていない場合にのみ機能します。
問題は 、次のように宣言されているときGetFooValue
の値を取得するために、どのように変更する必要があるかですFoo
strict private class var Foo: Integer;