function TForm1.ShowMethodAddress(aObj: TDerived; const sData: String) : Pointer;
var
aPtr : Pointer;
sResult : String;
begin
try
aPtr := aObj.MethodAddress(sData);
sResult := Format('%s : %x', [sData + '位于', Integer(aPtr)]);
Memo1.Lines.Add(sResult);
except
on e : Exception do
begin
sResult := Format('%s : %s', [sData, e.Message]);
Memo1.Lines.Add(sResult);
end;
end;
Result := aPtr;
end;
procedure TForm1.ShowFieldAddress(aObj: TDerived; const sData: String);
var
aPtr : Pointer;
sResult : String;
begin
try
aPtr := aObj.FieldAddress(sData);
sResult := Format('%s : %x', [sData + '位于', Integer(aPtr)]);
Memo1.Lines.Add(sResult);
except
on e : Exception do
begin
sResult := Format('%s : %s', [sData, e.Message]);
Memo1.Lines.Add(sResult);
end;
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
sData : String;
aPtr : Pointer;
begin
aPtr := Pointer(@Self.OnClick);
sData := MethodName(aPtr);
sData := Format('%x : %s', [Integer(aPtr), sData]);
Memo1.Lines.Add(sData);
end;