如何判断某个对象是否有某个属性(public级别的属性)

肥仔胧 2007-07-31 08:45:48
GetPropInfo可以得到某个对象的Published出来的属性,但是无法判断Public级别的属性
现在我想判断的是某个对象是否有某个属性,该属性却又是public级别的,请问要如何判断呢?
...全文
285 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
勇者无敌_ 2007-08-27
  • 打赏
  • 举报
回复
procedure GetClassProperties(AClass: TClass; AStrings: TStrings);
var
PropCount, I: SmallInt;
PropList: PPropList;
PropStr: 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;
PropStr := PropStr + PropList[I]^.Name;
PropStr := PropStr + ': ' + PropList[I]^.PropType^.Name;
AStrings.Add(PropStr);
end;
FreeMem(PropList);
end;
肥仔胧 2007-08-23
  • 打赏
  • 举报
回复
ding
cncharles 2007-08-03
  • 打赏
  • 举报
回复
VMT是可以解决的吧, 好像Delphi6 开发人员指南中有相关的代码, 楼主找找.
肥仔胧 2007-08-03
  • 打赏
  • 举报
回复
没有什么方法了吗
肥仔胧 2007-08-01
  • 打赏
  • 举报
回复
等待高手
constantine 2007-08-01
  • 打赏
  • 举报
回复
太高深了
肥仔胧 2007-08-01
  • 打赏
  • 举报
回复
madyak 2007-07-31
  • 打赏
  • 举报
回复
不太清楚,如果是我,就找源码,用眼睛找。
肥仔胧 2007-07-31
  • 打赏
  • 举报
回复
如果没有该怎么处理呢?
hongqi162 2007-07-31
  • 打赏
  • 举报
回复
GetPropInfo是根据类的RTTI指针和属性的名称字符串,返回属性的信息TPropInfo的指针
hsmserver 2007-07-31
  • 打赏
  • 举报
回复
属性必须定义在published段,才行,貌似public没有
肥仔胧 2007-07-31
  • 打赏
  • 举报
回复
没有概念了,即使从VMT入手,当你要实现如SetPropinfo时,又该如何?
Harryfin 2007-07-31
  • 打赏
  • 举报
回复
试试直接从vmt入手不知道行不行。
肥仔胧 2007-07-31
  • 打赏
  • 举报
回复
当如果用眼睛找不到的时候该怎么办呢?

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧