Basic COM  «Prev  Next»
Lesson 1

Component Object Model Basics

Component Software

COM, as its name indicates, is a specification and a set of development paradigms that supports the development of software components. But what is a software component?
In general - a software component is a module that follows some component specification. The two most popular component software technologies are COM and JavaBeans.
Components normally provide functionality via a set of functions or methods. Unlike C++ libraries - we do not need the class definition of a component, nor do we need to link to a component. All we need is a definition of its services and a way to access it.

We integrate with a component at runtime by having a service provider load the component. Once the component is loaded we can access its services. This is called binary-level integration.
A common metaphor used by components is to provide properties, methods, and events or exceptions. Component developers indirectly expose data as properties. Properties are set via "get" and "set" methods. A component is asked to perform an action via a method call. Events or exceptions are notifications sent from the component to the module using the component.
Application developers can use components to build applications by loading the components, getting and setting its properties, calling its methods, and fielding events or exceptions from the component.

Module introduction

To be an effective COM programmer, you must spend some time studying COM fundamentals. This module and the next module discuss core COM concepts. These will provide a foundation for understanding how the active template library (ATL) supports COM development. Your time spent understanding core COM concepts will make your COM programming efforts more efficient.
In this module, we will explore COM's binary standard via method and interface requirements. We will examine the IUnknown interface, describing interfaces with
  1. interface definition language (IDL),
  2. COM objects,
  3. interface navigation, and
  4. reference counting.
Finally, we will use IDL to describe a COM object and its interfaces and to produce a type library.
At the end of the module you will be able to:
  1. Develop IUnknown methods for interface navigation and reference counting
  2. Develop your own custom COM interfaces
  3. Use IDL to describe COM interfaces and COM objects
  4. Use IDL to produce a type library

Getting the most out of this module

To get the most out of this module, you should be familiar with the following C++ concepts:
  1. classes and structures,
  2. constructors,
  3. inheritance,
  4. multiple inheritance,
  5. virtual functions, and
  6. pure virtual functions.
You do not have to be an expert in these areas.If you need a refresher, check out one of the books recommended on the Resources page.

COM Programming with Microsoft .NET