Basic COM   «Prev  Next»
Lesson 5 COM servers
Objective Understand the tasks required of COM servers.
The next step in our study of COM is to examine the role played by COM Servers. A COM server is an executable module that provides specific required functionality.

Tasks required of COM servers

All COM servers must:
  1. Register all COM classes in the system registry (i.e., register the CLSID andInProcServer32 under
    HKEY_CLASSES_ROOT\clsid\{clsid-xxx }_.
  2. Unregister all of its COM classes.
  3. Create class objects, usually as class factories, and provide a pointer to the class object's object creation interface, usually IClassFactory, to the COM runtime system.
  4. Keep track of reference counts on instances of its COM objects and server lock counts. A server's execution can be terminated if none of its COM objects are in use and the lock counts are 0.

Required task execution in COM servers


How COM servers perform required tasks depends on the type of COM server. COM supports several different types of servers: in-process, local, remote, NT-service based, and surrogate DLL servers.
An in-process COM server resides in a dynamic link library (DLL). In-process servers have all the properties of Win32 DLLs. They are run in the same address space as the COM client. A local server resides in its own executable (i.e. *.exe file). It runs in a different process than the COM client. A remote server runs on a different machine than the client.
An NT-service-based server runs as an NT service. A surrogate DLL server is an in-process server that is loaded and run by a "surrogate" process. From the client's perspective, it appears to be a local or remote server.
This course will focus on in-process servers. The following lessons will discuss how an in-process server registers and unregisters its COM objects, creates and manages class factories, and supports unloading.