Eu lanço mão do seguinte algoritmo:
function GetClassHierarchy(poList: TStringList; oClassBase: TClass): Boolean;
var
oClass: TClass;
begin
Result := False;
if (Assigned(poList)) then
begin
poList.Clear;
oClass := oClassBase;
while (Assigned(oClass)) do
begin
poList.Insert(0,oClass.ClassName);
oClass := oClass.ClassParent;
end;
end;
end;
Exemplo da utilização:
procedure TForm1.Button9Click(Sender: TObject); var slList : TStringList; begin slList := TStringList.Create; Unt_RotinasLog.GetClassHierarchy(slList,TSQLQuery); Self.Memo1.Lines.Text := slList.Text; FreeAndNil(slList); end;
Resultado para o exemplo acima:
TObject
TPersistent
TComponent
TDataSet
TWideDataSet
TCustomSQLDataSet
TSQLQuery
Show!