读杨老师《COM设计与应用》18篇 下
9 IDispatch接口
IDispatch接口在MSDN中的定义This interface exposes objects, methods, and properties to
Automation programming tools and other applications.
我的理解是,实际上是将一个对象的接口暴暴露给脚本或IE
下面是IDispatch接口的四个函数
IDispatch::GetIDsOfNames Maps a single member name and an optional set of parameter names
to a corresponding set of integer dispatch identifiers (DISPIDs), which can then be used
on subsequent calls to IDispatch::Invoke.
IDispatch::GetTypeInfo Retrieves the type information for an object.
IDispatch::GetTypeInfoCount Retrieves the number of type information interfaces that an
object provides, either 0 or 1.
IDispatch::Invoke Provides access to properties and methods exposed by an object.
最重要的就是这个Invoke,通过设置IDipID,实现了一个接口函数调用多个功能,有点像窗口的消息
处理函数,根据不同的消息采用不同的处理方式,另外,GetIDsofNames提供将函数名转化为DispID的功