{"id":521,"date":"2022-02-02T09:09:25","date_gmt":"2022-02-02T09:09:25","guid":{"rendered":"https:\/\/efmsoft.com\/?page_id=521"},"modified":"2022-02-05T06:03:18","modified_gmt":"2022-02-05T06:03:18","slug":"component-object-model-com","status":"publish","type":"page","link":"https:\/\/efmsoft.com\/component-object-model-com\/","title":{"rendered":"Component Object Model (COM)"},"content":{"rendered":"

COM, or Component Object Model, is an object-based software architecture that allows applications to be built from binary software components. Component Object Model (COM) is a binary-interface standard for software components introduced by Microsoft in 1993. It is used to enable inter-process communication object creation in a large range of programming languages. COM is the basis for several other Microsoft technologies and frameworks, including OLE, OLE Automation, Browser Helper Object, ActiveX, COM+, DCOM, the Windows shell, DirectX, UMDF and Windows Runtime.<\/p>\n

The essence of COM is a language-neutral way of implementing objects that can be used in environments different from the one in which they were created, even across machine boundaries. For well-authored components, COM allows reuse of objects with no knowledge of their internal implementation, as it forces component implementers to provide well-defined interfaces that are separated from the implementation. The different allocation semantics of languages are accommodated by making objects responsible for their own creation and destruction through reference-counting. Type conversion casting between different interfaces of an object is achieved through the QueryInterface method. The preferred method of “inheritance” within COM is the creation of sub-objects to which method “calls” are delegated.<\/p>\n

\"Component<\/p>\n

As defined by Microsoft, the Component Object Model (COM<\/a>) is an object-based software architecture that allows applications to be built from binary software components. COM is the foundation for various Microsoft technologies including OLE, ActiveX, Distributed COM (DCOM), COM+, and Microsoft Transaction Server (MTS).<\/p>\n

COM is not a programming language, rather it is a specification. The goal of COM is to allow applications to be built using components. These COM components can be created by different vendors, at different times, and using different programming languages. Also, COM components can run on different machines and different operating systems.<\/p>\n

The following concepts are fundamental to the way COM works:<\/p>\n

 <\/p>\n

COM Interfaces<\/h4>\n

A group of related functions implemented by the COM class. COM interfaces are the mechanisms by which COM objects expose their functionality to applications and other components. An interface is a table of pointers to functions that are implemented by the object. The table represents the interface and the functions to which the table points represent the methods of that interface. COM objects can expose multiple interfaces. Each interface has its own unique interface ID (IID).<\/p>\n

IUnknown<\/h4>\n

This is the basic Component Object Model interface on which all other interfaces are based; it provides reference counting and interface querying mechanisms. IUnknown allows navigation to all other interfaces exposed by the object.<\/p>\n

Reference counting<\/h4>\n

This is a mechanism by which an interface determines it is no longer being used and is, therefore, free to remove itself. IUnknown uses the methods AddRef and Release to implement reference counting.<\/p>\n

QueryInterface<\/h4>\n

This is the IUnknown method used to query an object for a given interface.<\/p>\n

Aggregation<\/h4>\n

This is a technique by which one object can make use of another.<\/p>\n

Marshaling<\/h4>\n

This mechanism lets objects be used across thread, process, and network boundaries, thus providing location independence.<\/p>\n

The Component Object Model defines several fundamental concepts that provide the model\u2019s structural underpinnings. These include:<\/p>\n