tags:

views:

111

answers:

2

I want to find a tool that can see all the interface, including the methods, properties, events, exposed by a COM(or ActiveX) component. Is such tool available?

+2  A: 

If the component has a typelib (in resources or shipped separately) you can use OLE View that comes with Visual Studio. You should use "View Typelib", not "Bind to File" there.

sharptooth
Thanks, but in OLE Viewer I can only see the interface but not the function names exposed in that interface. What I want is the more detailed information.
Bin Chen
No, you see everything included into typelib. Now it depends on the settings of the application that generated that typelib what is included there. For example, if you use MIDL to parse an IDL file containing an interface marked [dual] the full function signatures are included as well.
sharptooth
Thanks. I am using VS.NET to generate all the information, is there any steps I can follow to generate the full function signatures?
Bin Chen
Oh, I think you were meaning "View Typelib" menu item in Ole Viewer! Yes I can see the function definitions now, thanks!
Bin Chen
Yes, exactly. I'll update the answer.
sharptooth
+3  A: 

It's not actually possible to build such a tool for ANY COM object, you might have some luck with specific objects. If a type library is available then you could use OLEView or you can programatically open and traverse the type library itself. Bear in mind that the contents of the type library is just what the developer wanted to include in it; there's nothing to stop objects implementing more interfaces than their type libraries say they do.

For objects without type libraries it's impossible to produce a general purpose tool:

  • Given the way that QueryInterface works you would have to ask the object under investigation if it supports every interface possible. Where would such a tool obtain a list of all possible interfaces that the object in question could support? Whilst it's true that some interfaces are registered in the registry due to proxy requirements not all interfaces are and it's by no means a requirement that they should be.
  • Once you know that an object supports a given interface how do you work out what methods that interface supports? If the interface derives from IDispatch then this is possible as that's the purpose of IDispatch, but for interfaces derived from IUnknown there is no way to programatically discover things about the interface.

You also have the added problem that some objects may have additional interfaces implemented for them by the proxy layer, for example, if an interface has been proxied then you will also be able to QueryInterface from it to IProxyManager though the object itself does not implement this interface (it's part of the proxy).

Len Holgate