Basic COM   «Prev  Next»
Lesson 1

COM Fundamentals and Basic Programming

This course discusses the Component Object Model also known as COM. We will begin by examining the fundamental concepts of COM, COM servers, COM objects, and COM interfaces. Once we have established a solid understanding of COM fundamentals, we will study the active template library, also known as ATL (formerly known as the ActiveX template library). Using the ATL, we will develop a COM object, PhBook, that implements a COM interface to manage a personal phone book. We will also develop a COM client, PhCliXX which uses the address information managed by PhBook.

COM: The Component Object Model

The Component Object Model (COM) forms the foundation upon which OLE and ActiveX technology is built. COM defines an API and a binary standard for communication between objects tha's independent of any particular programming language or (in theory) platform. COM objects are similar to the VCL objects you are familiar with, except that they have only methods and properties associated with them, not data fields. A COM object consists of one or more interfaces, which are essentially tables of functions associated with that object. You can call an interface's methods just like the methods of a Delphi object. The component objects you use can be implemented from any EXE or DLL, although the implementation is transparent to you as a user of the object because of a service provided by COM called marshaling. The COM marshaling mechanism handles all the intricacies of calling functions across the boundaries of processes and machines, which makes it possible to use a 32-bit object from a 16-bit application or access an object located on machine A from an application running on machine B. This intermachine communication is known as Distributed COM (DCOM).


The Role of COM in Microsoft Technologies

Microsoft Component Object Model (COM) is indeed a legacy technology when compared to modern technologies like .NET, but it has played a significant role in the history of software development, particularly in the Windows ecosystem. To understand the importance of COM from a historical perspective, developers should consider the following key points:
  1. Origins and Evolution:
    • COM was introduced by Microsoft in the early 1990s as a way to facilitate the development of reusable software components.
    • It evolved from OLE (Object Linking and Embedding) and was later extended with DCOM (Distributed COM) to enable distributed computing.
  2. Foundation for Windows Ecosystem:
    • COM was the foundation for various Windows technologies, including ActiveX controls, which allowed for embedding components in web browsers and other applications.
    • Many core Windows system services and components are implemented as COM objects, making it an integral part of the Windows operating system.
  3. Interoperability:
    • COM enabled interoperability between software components written in different programming languages, making it possible to integrate components developed in C++, Visual Basic, and other languages seamlessly.
    • This was crucial for the Windows platform, as it allowed developers to leverage existing codebases and libraries.
  4. Reusability:
    • COM promoted the concept of code reusability by encapsulating functionality in self-contained COM objects.
    • Developers could create custom COM components and reuse them across multiple applications, reducing development time and effort.
  5. Challenges:
    • COM development was complex and error-prone, often requiring manual memory management, reference counting, and intricate interface definitions.
    • Versioning and deployment of COM components could be challenging, leading to issues with compatibility.
  6. Transition to .NET:
    • With the introduction of the .NET Framework in the early 2000s, Microsoft shifted its focus to a more modern, managed code platform.
    • .NET offered a simpler and more robust framework for developing Windows applications, reducing many of the complexities associated with COM.
  7. Legacy Support:
    • Despite its legacy status, COM remains relevant in certain scenarios. Existing COM components continue to be used in legacy applications, and COM interop libraries in .NET enable integration with modern technologies.

In conclusion, while Microsoft COM is a legacy technology, it played a crucial role in the history of Windows software development by enabling interoperability, reusability, and component-based architecture. Understanding COM's historical significance can help developers appreciate the evolution of software development on the Windows platform and its transition to more modern technologies like .NET.

Course goals

By the end of this course you will be able to:
  1. Describe the Component Object Model, i.e., COM servers, objects, and interfaces
  2. Use basic COM programming technology, including interface pointers, IUnknown interface navigation, IUnknown reference counting, IclassFactory, the interface definition language (IDL), Microsoft IDL compiler (MIDL), and the ATL
  3. Understand and use type libraries as part of the COM development process
  4. Develop source code for a basic in-process COM objects/servers and COM clients using the ATL

The series

COM Fundamentals I is the first of DistributedNetworks's two-part COM Series.

SEMrush Software