Most COM applications use class factories as their class objects. A class factory implements COM interface IClassFactory.
You should be familiar with class objects and using multiple inheritance to implement a COM object to get the most from this lesson.
IClassFactory has the following methods.
IUnknown: Because IClassFactory is a COM interface, it must implement IUnknown methods (QueryInterface, AddRef, and Release).
HRESULT CreateInstance (IUnknown *pOuter, const IID& riid, VOID **ppv);
This method is called by a client to have the class factory create an instance of its associated COM object.
Parameter pOuter is used for aggregation, for now, assume its value is NULL.
Parameter riid is the IID of an interface, within the newly created object instance, that the client wants.
Parameter ppv is an output parameter that will hold the interface pointer specified in parameter riid.
HRESULT LockServer (BOOL fLock);--This method is called to increment or decrement a lock counter within a COM server.
If fLock is TRUE, the counter should be incremented; if it is FALSE, the counter should be decremented.
This method is often used to keep a COM server in memory when none of its COM objects are in use.