What is the difference between IDispatch and IUnkown in COM? [closed]

纵饮孤独 提交于 2020-05-14 13:54:46

问题


I have read and saw example for COM, but I couldn't clearly get there Interface difference.


回答1:


IUnknown is the primal COM interface. It provides the basic ability to "cast" a instance of a COM object to any of it's supported interfaces (QueryInterface).

IDispatch builds on IUnknown adding the facility to discover at run-time the attributes and interfaces supported by the specified COM object. This allows for late-binding and dynamic-binding. A remedial reflection of sorts. With IDispatch, an application can discover the capability of components and invoke discovered methods (which was simplistically called automation).

See Implementing the IDispatch Interface [Automation] on MSDN (resurrected from WayBack Machine - current online version).




回答2:


IUnkown is the basic interface for all COM interfaces.

IDispatch exposes an interfacea for objects, methods and properties to programming tools and other applications that support Automation.




回答3:


The IDispatch interface inherits from the IUnknown interface. Please have a look at the below link.

IDispatch

IUnknown



来源:https://stackoverflow.com/questions/37937360/what-is-the-difference-between-idispatch-and-iunkown-in-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!