Enumerate COM object (IDispatch) methods using ATL?

前端 未结 3 1709
我在风中等你
我在风中等你 2020-12-05 21:24

Using ATL (VS2008) how can I enumerate the available methods available on a given IDispatch interface (IDispatch*)? I need to search for a method with a specif

3条回答
  •  无人及你
    2020-12-05 21:33

    You can enumerate the methods an IDispatch exposes through the type info. There are two ways to get the type info:

    • through the type library (if any) for the dispinterface.
    • through calling IDispatch::GetTypeInfo.

    Unfortunately, an IDispatch implementation is not obligated to provide type info about the methods and properties it implements.

    If it does, however, the basic enumerating involves calling ITypeInfo::GetTypeAttr to get the TYPEATTR for the interface and looking at the number of implemented methods (cFuncs) and variables (cVars) and looping over these and calling ITypeInfo::GetFuncDesc() or ITypeInfo::GetVarDesc(). Of course, there are lot more details you will have to deal with as I can list here, but this should be a good starting point for your exploration.

    Here's a nice article explaining the process in more details with code in VB.Net.

提交回复
热议问题