Emulating Other Servers
The final topic related to COM Servers for this chapter is what is known as emulation: the ability for one server associated with one CLSID to emulate a server of another CLSID. A server that can emulate another is responsible for providing compatible behavior for a different class through a different implementation. This forms the basis for allowing end users the choice in which servers are used for which objects, as long as the behavior is compatible between those servers.
As far as COM is concerned, it only has to provide some way for a server to indicate that it wishes to emulate some CLSID. To that end, the COM Library supplies the function CoTreatAsClass to establish an emulation that remains in effect (persistently) until canceled or changed. In addition it supplies CoGetTreatAsClass to allow a caller to determine if a given CLSID is marked for emulation.