I Need to access a strict private class var value of a class using his instance and a offset to the variable.
so far tried this , check this sample class
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;
As you see the function GetFooValue works only when the foo variable is not declarated like a class var.
The question is how I must modify the GetFooValue
in order to get the value of Foo
when is declarated like strict private class var Foo: Integer;
+ 4
? And what happens, if you create an object of typeTFoo
(that is, if you "use the class"), before calling GetFooValue? – Raminclass var
. – Ironbound