What is the difference between COM and OLE?

TASNEEMUDDIN picture TASNEEMUDDIN · Feb 5, 2009 · Viewed 16.9k times · Source

What is the difference between COM and OLE, if any?

Answer

Ben picture Ben · Jan 19, 2012
  • OLE = Object Linking and Embedding
  • DDE = Dynamic Data Exchange
  • COM = Component Object Model

OLE: This is a method of linking parts of one document to parts of another. For example, having a PowerPoint slide with an Excel chart embedded into it. When the Excel spreadsheet is updated, the chart should update too. When you reopen PowerPoint, magically it has! (This example is a linked object.) Embedded objects are the same only the Excel spreadsheet doesn't exist in an external file, the data for the spreadsheet is contained within the PowerPoint file.

You can embed Excel, Word and PowerPoint documents into each other with linked objects. Other applications were written specifically to support being embedded into Word, such as Microsoft Equation Editor.

OLE 1 was built on DDE, which used window messages to notify applications when source data changed, and typically passed data around by using HGLOBAL global memory handles.

OLE 2 was built on COM.

COM is an language neutral, object-oriented component model and ABI based on DCE RPC. As an RPC system it supported remote calls between processes on the same machine, and later, with DCOM, on different machines. Initially COM was used as part of the architecture of MAPI (which uses the COM object model but not the COM registration services) before being formally launched on its own as a general object model complete with registry and object activation and other services. (Monikers and structured storage for example.)

OLE Automation has nothing to do with OLE - it's a branding connection only. OLE Automation is a Visual Basic-compatible subset of COM which supports basic datatypes only (for example no unsigned integers or structs) but including objects (COM interfaces).

OLE Controls however ARE related to OLE. They are visual components primarily targeted at Visual Basic users from VB 4 onwards, but the visual elements are provided using the embedding facilities of OLE 2. They can also be hosted (in theory, if properly written) by anything capable of hosting an OLE 2 embedded object, and were often used in C++ applications too. They typically use OLE Automation compatible interfaces for programming at runtime.

ActiveX control is a marketing term for COM objects, from the time when Microsoft were attempting to popularise the technology for extending web applications.