谢谢

解决方案 »

  1.   

    去看《Delphi5开发人员指南》一书中RTTI那一章,里面讲解的很详细了
      

  2.   

    请继续关注这个问题
    http://expert.csdn.net/Expert/TopicView1.asp?id=1793141
    谢谢
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      {$M+}
      TNewRec  = class
      private
        FA : String;
        FD : Char;
        FC : Integer;
        FB : String;
        FE : TDateTime;
      published
        property A: string read FA write FA;
        property D: Char read FD write FD;
        property C: Integer read FC write FC;
        property B: string read FB write FB;
        property E: TDateTime read FE write FE;
      end;
      {M-}  TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    uses TypInfo;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      PropList: PPropList;
      PropCount: Integer;
      I: Integer;
    begin
      PropCount := GetPropList(TNewRec.ClassInfo, PropList);
      for I := 0 to PropCount - 1 do
        Memo1.Lines.Add('字段名: ' + PropList[I].Name + '====' +
          '类型: ' +
          Copy(GetEnumName(TypeInfo(TTypeKind), Integer(PropList[I].PropType^.Kind)), 3 , MaxInt));
    end;end.
      

  4.   

    在D5下,这样procedure TForm1.Button1Click(Sender: TObject);
    var
      PropList: PPropList;
      PropCount: Integer;
      I: Integer;
    begin
      PropCount := GetTypeData(TNewRec.ClassInfo)^.PropCount;
      GetMem(PropList, PropCount * SizeOf(Pointer));
      try
        GetPropInfos(TNewRec.ClassInfo, PropList);
        for I := 0 to PropCount - 1 do
          Memo1.Lines.Add('字段名: ' + PropList[I].Name + '====' +
            '类型: ' +
            Copy(GetEnumName(TypeInfo(TTypeKind), Integer(PropList[I].PropType^.Kind)), 3 , MaxInt));
      finally
        FreeMem(PropList);
      end;
    end;