OOPortal OOPortal

Basic COM   «Prev  Next»
Lesson 7In-process COM servers and DllGetClassObject
ObjectiveDescribe what DllGetClassObject does.

In-process COM Servers and DllGetClassObject

In-process servers provide class factories via function DllGetClassObject:
STDAPI DllGetClassObject(const CLSID&
rclsid, const IID& riid, VOID ** ppv);

COM calls DllGetClassObject on behalf of a COM client passing in a CLSID, an IID, and a VOID ** output parameter.
The CLSID is the CLSID of the COM object we want a class factory for; the IID is IID_IClassFactory.
If the server supports the requested COM object, it creates a class factory and calls QueryInterface in the new class factory. The following code demonstrates an implementation of DllGetClassObject.

These declare and implement a class factory for O1. IClassFactory, like all COM interfaces, must implement IUnknown as its first three methods. Following that are the methods of IClassFactory. CreateInstance and LockServer were covered earlier in this module.

Public iClassFactory