| Lesson 3 || IClassFactory methods |
| Objective || Learn IClassFactory methods. |
Most COM applications use class factories as their class objects. A class factory implements COM interface
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.
IClassFactory is a COM interface, it must implement
IUnknown methods (
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.
pOuter is used for aggregation, for now, assume its value is
riid is the IID of an interface, within the newly created object instance, that the client wants.
ppv is an output parameter that will hold the interface pointer specified in parameter
HRESULT LockServer (BOOL fLock);--This method is called to increment or decrement a lock counter within a COM server.
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.