COM Servers

From RAD Studio
Jump to: navigation, search

Go Up to Parts of a COM Application


A COM server is an application or a library that provides services to a client application or library. A COM server consists of one or more COM objects, where a COM object is a set of properties and methods.

Clients do not know how a COM object performs its service; the object's implementation remains encapsulated. An object makes its services available through its interfaces.

In addition, clients do not need to know where a COM object resides. COM provides transparent access regardless of the object's location.

When a client requests a service from a COM object, the client passes a class identifier (CLSID) to COM. A CLSID is simply a GUID that identifies a COM object. COM uses this CLSID, which is registered in the system registry, to locate the appropriate server implementation. Once the server is located, COM brings the code into memory, and has the server instantiate an object instance for the client. This process is handled indirectly, through a special object called a class factory (based on interfaces) that creates instances of objects on demand.

As a minimum, a COM server must perform the following:

  • Register entries in the system registry that associate the server module with the class identifier (CLSID).
  • Implement a class factory object, which manufactures another object of a particular CLSID.
  • Expose the class factory to COM.
  • Provide an unloading mechanism through which a server that is not servicing clients can be removed from memory.

Note: Delphi wizards automate the creation of COM objects and servers.

Topics

See Also