COM / OLE / ActiveX / IDispatch confusion

时光怂恿深爱的人放手 提交于 2019-12-03 03:23:50
Ofek Shilon

Found some quotes from COM Programming by Example:

Another thing you'll quickly find with COM is that marketing had a field trip day with the terminology. Rather then helping to promote understanding, you'll find in most cases it promotes mystery. ... OLE, ActiveX, Remotable Objects - which one means what this week? ...

COM evolved out of the solution to a specific problem - how to allow a word processor to edit the spreadsheet in a letter without the user having to exit the word processor to do it. This solution was called OLE. ... However, with the second release of OLE (OLE2), its creators modified OLE32.DLL to expose more of the basic functionality of OLE so that its API could be used to allow any application to acess the functionality of another. This API, which hasn't changed much since 1993, is what is considered to be the COM API. ...

Once the COM API was exposed, Microsoft used it to create what were then called OLE controls to allow sophisticated controls (e.g., buttons that spiral, list boxes that play music) written in Visual C++ to be accessible to Visual Basic applications. Eventually this same technology was used to allow a control to be downloaded and used by your web browser. At this point, the name changed to ActiveX controls or just plain ActiveX purely for marketing reasons. Although you can package any functionality in an ActiveX Control, its requrirements have been specialized for supporting a user interface control.

I'm still curious about the very last sentence - must a COM object satisfy some additional requirements to qualify as an ActiveX control? - but its enough to let it go.

Thanks for your answers!

ActiveX is marketing-ese for COM, although ActiveX is usually used in the context of "ActiveX controls" which are GUI objects.

IDispatch is an interface implemented by COM objects so that client programs can call its methods dynamically at run-time (late-binding), as opposed to at compile time where all the methods and argument types need to be known ahead of time.

OLE is the earlier version of COM.

Regarding OLE: COM has its roots in OLE. But today, OLE may be considered to be built on top of COM and is mostly used for what its name suggests -- document linking and embedding. While COM itself defines only a couple of interfaces itself (IUnknown, IClassFactory, IMalloc etc), OLE adds a whole bunch of additional interfaces like IMoniker, IOleItemComtainer, etc.

To sum up: COM is the foundation, ActiveX and OLE are layers on top of COM.

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