【发布时间】:2023-03-25 09:35:02
【问题描述】:
当我在 Delphi 7 中定义这样的类时:
TPerson = class(TObject)
private
FLName: string;
FFName: string;
FAge: integer;
FBDate: TDate;
public
published
property FName: string read FFName write FFName;
property LName: string read FLName write FLName;
property Age: integer read FAge write FAge;
property BDate: TDate read FBDate write FBDate;
end;
procedure ListComponentProperties(AObject: TObject; Strings: TStrings);
var
Count, Size, I: Integer;
List: PPropList;
PropInfo: PPropInfo;
PropValue: string;
begin
Count := GetPropList(AObject.ClassInfo, tkAny, List);
Size := Count * SizeOf(Pointer);
GetMem(List, Size);
try
Count := GetPropList(AObject.ClassInfo, tkAny, List);
for I := 0 to Count - 1 do
begin
PropInfo := List^[I];
PropValue := VarToStr(GetPropValue(AObject, PropInfo^.Name));
end;
finally
FreeMem(List);
end;
end;
并且我想通过 ListComponentProperties 获取其已发布属性的列表,将显示错误消息。该错误与以下命令和 AObject.ClassInfo 有关:
Count := GetPropList(AObject.ClassInfo, tkAny, List);
任何帮助将不胜感激。
【问题讨论】:
-
以后当您提出与错误消息相关的问题时,请在您的问题中包含错误消息,并逐字引用。