I'm writing a control that should be able to display any list of data. What I wanted to do, was to mimic the for-in construct in that I check for a public GetEnumerator function that contain a Current property and a MoveNext method.
I've determined the following:
- I can check the existance of a method by simply calling MethodAddress on my object. If I get the address, the method exists.
- I can use RTTI to check the return type of the method.
- I can use RTTI to check for the property and to read it.
In-between though, I am missing little bits of info:
- How do I call the method, given its address? Do I just write a definition (like I would for imports), cast the address and call it?
- Checking the return type of the method requires calling GetTypeData with its PTypeInfo. I get the PTypeInfo by calling TypeInfo on a type. So how do I get a PTypeInfo for a given method, given only its address?