GetPropInfo可以得到某个对象的Published出来的属性,但是无法判断Public级别的属性
现在我想判断的是某个对象是否有某个属性,该属性却又是public级别的,请问要如何判断呢?

解决方案 »

  1.   

    属性必须定义在published段,才行,貌似public没有
      

  2.   

    GetPropInfo是根据类的RTTI指针和属性的名称字符串,返回属性的信息TPropInfo的指针
      

  3.   

    试试直接从vmt入手不知道行不行。
      

  4.   

    没有概念了,即使从VMT入手,当你要实现如SetPropinfo时,又该如何?
      

  5.   

    VMT是可以解决的吧, 好像Delphi6 开发人员指南中有相关的代码, 楼主找找.
      

  6.   

    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;