What is the difference between COM and OLE, if any?
- 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.
COM is OLE evolved. OLE was a set of interfaces and data storage mechanisms to facilitate sharing data between applications. COM was the natural extension of using interfaces not only to share data, but runtime functionality - where the data was fronted by actual mechanisms to facilitate use. I've always pictured it roughly as the difference between C and C++, where with C, you can share header files and structures, and with C++ you share encapsulated objects.
As a bit of a soapbox, I still miss OLE Structured Storage, since there is something nice about sharing opaque data storage between collaborating systems. Seeing as drag-and-drop/clipboard still depends on it, I wonder what the .Net replacement will be?
The OLE technology predates COM as a separate entity by a significant amount of time. Before that, OLE was implemented as a way of Embedding and Linking Objects. The classic example is that of embedding a spreadsheet within a word document. The underlying technology of COM was enabled so that other languages such as VB could interact with those objects as well.
Then, historically, we had a lot of server type programmers which were looking on these cool things like language independence, reference counting and threading models with envy, but really didn't care too much about the embedding technology at all. The logical thing to do was to split out the underlying server functionality as COM - this was a more naturally low-level API.
Both technologies still exist. OLE is kind of linked up with or may be the same as ActiveX these days.
© 2022 - 2024 — McMap. All rights reserved.