The Component Object Model

Many of the APIs in the DirectX 2 SDK are composed of objects and interfaces based on the Component Object Model (COM). COM is a foundation for an object-based system that focuses on reuse of interfaces and is the model at the heart of OLE programming. It is also an interface specification from which any number of interfaces can be built. It is an object model at the operating system level.

Many DirectX 2 APIs are instantiated as a set of OLE objects. The object can be considered a black box that represents the hardware and requires communication with applications through an interface. The commands sent to and from the object through the COM interface are called methods. For example, the IDirectDraw::GetDisplayMode method is sent through the IDirectDraw interface to get the current display mode of the display adapter from the DirectDraw object.

Objects can bind to other objects at run time and use the implementation of interfaces provided by the other object. If you know an object is an OLE object, and what interfaces that object supports, your application, or another object, can determine what services the first object can be called upon to perform. One of the methods inherited by all OLE objects, called QueryInterface, lets you determine what interfaces are supported by an object and create pointers to these interfaces.