Uses TypInfo;
procedure GetClassProperties(AClass: TComponent; AStrings: TStrings);
var
PropCount, I: SmallInt;
PropList: PPropList;
PropStr, sClass, sName, sValue: string;
begin
PropCount := GetTypeData(AClass.ClassInfo).PropCount;
GetPropList(AClass.ClassInfo, PropList);
for I := 0 to PropCount - 1 do
begin
case PropList[I]^.PropType^.Kind of
tkClass : PropStr := '[Class] ';
tkMethod : PropStr := '[Method]';
tkSet : PropStr := '[Set] ';
tkEnumeration: PropStr := '[Enum] ';
else
PropStr := '[Field] ';
end;
var
PropCount, I: SmallInt;
PropList: PPropList;
PropStr, sClass, sName, sValue: string;
begin
PropCount := GetTypeData(AClass.ClassInfo).PropCount;
GetPropList(AClass.ClassInfo, PropList);
for I := 0 to PropCount - 1 do
begin
case PropList[I]^.PropType^.Kind of
tkClass : PropStr := '[Class] ';
tkMethod : PropStr := '[Method]';
tkSet : PropStr := '[Set] ';
tkEnumeration: PropStr := '[Enum] ';
else
PropStr := '[Field] ';
end;
sName := PropList[I]^.Name; //名稱
sValue := GetPropValue(AClass, sName ); //值
sValue := GetPropValue(AClass, sName ); //值
sClass := PropList[I]^.PropType^.Name; //類別
PropStr := PropStr + PropList[I]^.Name;
PropStr := PropStr + ': ' + sClass ;
PropStr := PropStr + ' Value='+sValue;
AStrings.Add(PropStr);
end;
FreeMem(PropList);
end;
PropStr := PropStr + ': ' + sClass ;
PropStr := PropStr + ' Value='+sValue;
AStrings.Add(PropStr);
end;
FreeMem(PropList);
end;