COM Objects and IDL
Microsoft's Component Object Model, or COM, is a specification for developing modular software components. COM is not a programming language or an API, but an implementation of a component architecture. A component architecture is a method of designing software components so that they can be easily connected together, reused, or replaced without re-compiling the application that uses them. Other examples of this methodology include the Object Management Group's Common Object Request Broker Architecture (CORBA) and Sun's JavaBeans technologies.
ActiveX controls are a special class of COM object that follow a set of Microsoft interface specifications; they are normally designed to present a user interface.
IDL for Windows supports three methods for using COM-based software components in your applications:
- Exposing a COM object as an IDL object
- Including an ActiveX control in an IDL widget hierarchy
Note
While COM components can be developed for numerous platforms, most COM-based software is written for Microsoft Windows platforms. IDL for Windows supports the inclusion of COM technologies, but IDL for UNIX does not. The chapters in this section will discuss COM in the context of Microsoft Windows exclusively.
What Are COM Objects?
A COM object, or component, is a piece of software that:
In addition to these criteria, a component may also supply a user interface that can be manipulated by the user. COM objects that supply a user interface and send events to the programs that use them are generally packaged as ActiveX controls, although it is not a requirement that an ActiveX control provide a user interface.
COM objects and ActiveX controls are nearly always packaged as Windows executable (.exe), dynamic link library (.dll), or object linking and embedding (.ocx) files.
Why Use COM Objects with IDL?
There are several reasons to use COM technologies alongside IDL:
- COM objects can be designed to use the facilities of the underlying Windows operating system. If you need access to Windows features not exposed within IDL, incorporating a COM object into your IDL program may provide the functionality you need.
- COM objects have been written to provide custom user interface elements or accomplish specific tasks. Many of these components are available to you free or at minimal cost. If you work exclusively in a Windows environment, incorporating a pre-written component in your IDL program may be faster than coding the same functionality in IDL.