||These declare and implement a class factory for
IClassFactory, like all COM interfaces, must implement
IUnknown as its first three methods.
Following that are the methods of
CreateInstance and LockServer were covered earlier in this module.
|Lines 18 and 19:
||We use the standard declaration of
DllGetClassObject. REFCLSID and REFIID are macros that preprocess to
"const CLSID&"and "const IID& when compiling in C++;
|| We check to see if this server supports the COM object by checking
rclsid. If the requested COM object is not supported,
CLASS_E_CLASSNOTAVAILABLE is returned (line 33).
| Lines 23 and 24:
|| An instance of the class factory for the requested COM class is instantiated.
| Line 26:
|| A call is made to
IClassFactory::QueryInterface to ask the newly created class factory if it supports the requested object creation interface in parameter
Normally this is
QueryInterface will also call
AddRef if the requested interface is supported.
||A check of the return status of the
| Lines 28 nd 29:
|| Executed if the caller (COM) asked for an object creation interface not support by the class factory. The only reason this would fail (barring bugs) is if the caller did not ask for either
| Line 34:
S_OK to indicate, to the caller, that the requested COM object is supported by the server and the object's object creation interface;
IClassFactory, has been placed in output parameter