tags:

views:

39

answers:

3

Given an instance of an ActiveX control, how do I enumerate it's interfaces? (I'd like to get the names of the interfaces).

A: 

No way. The idea behind COM interfaces is that you ask the object - "please give me interface XYZ if you support it) and the object decides how to respond - provide the reference to itself or expose the interface of some internal object etc. So you can't know what interfaces the object "supports" without asking the object as described above. This was the design decision of COM designers.

Eugene Mayevski 'EldoS Corp
+1  A: 

Unfortunately, that's not something COM is designed for. At the basic COM level, you can merely ask an object whether it supports a specific UUID-identified interface, one at a time. Since there are a lot of potential UUID's, getting an exhaustive list that way would take quite a bit of time! While most object implementations would track the list of supported interfaces internally, there is no standard COM way of accessing those lists from the outside. And even if there were, you could only get a programmatic name of the interface by looking their UUID's up in the registry, which isn't always reliable.

ActiveX objects (a tricky term!) tend to support automation through IDispatch. If the objects are well behaved, you will able to get some information on the methods they support through GetTypeInfo(). This won't include the names of the interfaces (if any) the methods belong to.

To summarize, COM is rather poor at object metadata.

Pontus Gagge
Thanks for the very detailed answer. However, I was looking for a practical solution which Paul's answer provided me, so I accepted that instead.
Tamás Szelei
+1  A: 

Like others have mentioned, the only way is to QueryInterface for all possible interfaces. And this is exactly what the Microsoft tool OleView does for you.

Paul Mitchell