is there way names of parameters of given method of class/object in array/delimited string in delphi 7? somehow this:
var s : string; asl : tstringlist; begin ... // using rtti calls in tmethodutility.collectparamnames s := tmethodutility.collectparamnames( tstringlist.addobject ); // or tmethodutility.collectparamnames( tstringlist.addobject, asl ); ... end;
thanks in advance!
it technically possible (otherwise ide's form designer not generate code component event handlers @ design-time), however, there important caveats hinder goal (and make particular example in question impossible resolve):
the necessary rtti generated properties declared
published
(such component events). rtti not generated methods (evenpublished
ones), or properties notpublished
.tobject
has publicmethodaddress()
method getting memory address ofpublished
method (the dfm streaming system uses when hooking event handlers), cannot necessary rtti method pointer alone.
if can match given method pointer value of published
event, can extract parameter names event's rtti. obtain typinfo.ppropinfo
pointer event using typinfo.getpropinfo()
function, pass proptype
field value typinfo.gettypedata()
function typinfo.ptypedata
pointer, , can iterate through paramlist
field (which array of records containing paramname
, typename
fields).
see following blog article on topic more details:
getting parameters of published methods.
for attempting, general-purpose solution require extended rtti introduced in delphi 2010 , not available in delphi 7. extended rtti not limited published
items, , much more detailed old-style rtti provides.
Comments
Post a Comment