OOPortal OOPortal





ATL Development   «Prev  Next»
Lesson 1

Introduction to Using ATL to build an in-process COM server

Com implementation Practices
In modules 2 and 3, we studied core COM and implementation practice concepts.
This module discusses how to use the active template library (ATL) to build an in-process server containing a COM object with two interfaces.
At the end of the module, you will be able to:
  1. Describe the role of the ATL framework
  2. Explain what ATL's core classes do
  3. Use the ATL COM-Wizard to generate an in-process COM server
  4. Add your own COM implementation classes into the ATL framework
  5. Add COM properties and methods into your COM objects



ATL is designed to simplify the process of creating efficient, flexible, lightweight controls. This module leads you through the creation of an ActiveX control, demonstrating many ATL and COM fundamentals.

COM Server

COM Server is some module of code, a DLL or an EXE, that implements one or more object classes (each with their own CLSID). A COM server structures the object implementations such that COM clients can create an use objects from the server using the CLSID to identify the object through the processes described. In addition, COM servers themselves may be clients of other objects, usually when the server is using those other objects to help implement part of its own objects. This chapter will cover the various methods of using an object as part of another through the mechanisms of containment and aggregation. Another feature that servers might support is the ability to emulate a different server of a different CLSID. The COM Library provides a few API functions to support this capability that are covered at the end of this chapter. If the server is an application, that is, an executable program, then it must follow all the requirements for a COM Application as detailed in Chapter 4. If the server is a DLL, that is, an in-process server or an object handler, it must at least verify the library version and may, if desired, insure that the COM Library is initialized. That aside, all servers generally perform the following operations in order to expose their object implementations:
  1. Allocate a class identifier-a CLSID-for each supported class and provide the system with a mapping between the CLSID and the server module.
  2. Implement a class factory object with the IClassFactory interface for each supported CLSID.
  3. Expose the class factory such that the COM Library can locate it after loading (DLL) or launching (EXE) the server.
  4. Provide for unloading the server when there are no objects being served and no locks on the server (IClassFactory::LockServer).