Rtti need to reference unit TypeInfo
The Getpropinfo function is used to get the RTTI pointer ppropinfo of the property. It has four overloaded forms, and the subsequent implementations of the three overloads are the first form of invocation. The Akinds parameter is used to restrict the type of the property, and nil is returned if the resulting ppropinfo does not belong to the specified type.
function Getpropinfo (typeinfo:ptypeinfo; const propname:string): Ppropinfo;
function Getpropinfo (instance:tobject; const propname:string; Akinds:ttypekinds = []): Ppropinfo;
function Getpropinfo (aclass:tclass; const propname:string; Akinds:ttypekinds = []): Ppropinfo;
function Getpropinfo (typeinfo:ptypeinfo; const propname:string; Akinds:ttypekinds): Ppropinfo;
//The following code loops through the Capiton of the button component on the form//method One:proceduretform1.setcaption;varPinfo:ppropinfo; I:integer;begin forI: =0 toSelf.controlcount-1 Do beginPInfo:= Getpropinfo (Self.controls[i],'Caption');//Getpropinfo, find Caption property according to ' Caption ' string ifPInfo <>Nil Then //if there isTButton (Self.controls[i]). caption:='ABC';//Modify Capiton End;End; method Two:proceduretform1.setcaption;varPinfo:ppropinfo; I:integer;begin forI: =0 toSelf.controlcount-1 Do beginPInfo:= Getpropinfo (Self.controls[i],'Caption'); ifPInfo <>Nil ThenSetpropvalue (Self.controls[i],'Caption','ABC'); End;End;
Reference: http://www.cnblogs.com/key-ok/p/3358804.html
Understanding run-Time type information (RTTI)