I need to get pointer to my class instance inside this instance. I can't use "Self" directly, I need store pointer for future usage. I tried next code:
type
TTest = class(TObject)
public
class function getClassPointer: Pointer;
function getSelfPointer: Pointer;
end;
class function TTest.getClassPointer: Pointer;
begin
Result := Pointer(Self);
end;
function TTest.getSelfPointer: Pointer;
begin
Result := Pointer(Self);
end;
And both result are wrong - this code:
test := TTest.Create;
Writeln('Actual object address: ', IntToHex(Integer(@test), 8));
Writeln('Class "Self" value: ', IntToHex(Integer(test.getClassPointer()), 8));
Writeln('Object "Self" value: ', IntToHex(Integer(test.getSelfPointer()), 8));
returns:
Actual object address: 00416E6C
Class "Self" value: 0040E55C
Object "Self" value: 01EE0D10
Please, help me understand, what is this "Self" value ? Is "Self" a pointer to this class instance ? How use this pointer to future use outside of this object ? How get proper pointer from this value ?