EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of COM/DCOM Questions #Next question

IClassFactory

All COM/DCOM server follows factory design pattern.IClassFactory class is the standard used in COM/DCOM to achieve this design. The IClassFactory interface contains two methods intended to deal with an entire class of objects, and so is implemented on the class object for a specific class of objects (identified by a CLSID).

IClassFactory::CreateInstance

The first method, CreateInstance, creates an uninitialized object of a specified CLSID, and the second,

IClassFactory::LockServer

LockServer, locks the object's server in memory, allowing new objects to be created more quickly and enhances performance of the program.

IClassFactory class prototype

class IClassFactory : public IUnknown {
  
  public:
    virtual HRESULT __stdcall CreateInstance(
            /* [in] */ IUnknown  *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [out] */ void **ppvObject) = 0;

    virtual HRESULT STDMETHODCALLTYPE LockServer(
            /* [in] */ BOOL fLock) = 0;
    };

IUnknown Methods

IClassFactory is derived from IUnknown so the vtable would list the function pointers of IUnknown abstruct methods.

  • QueryInterface - Returns pointers to supported interfaces.
  • AddRef - Increments reference count.
  • Release - Decrements reference count.

IClassFactory Methods

IClassFactory's own methods will follow after IUnknown's methods.

  • CreateInstance - Creates an uninitialized object.
  • LockServer - Locks object application open in memory.

CLIENT Create functions

CoGetClassObject function to get an IClassFactory interface pointer to the class object, call the CreateInstance method of this interface to create a new uninitialized object. This approach is good when multiple instances of the same class or different classes are needed.

It is not, however, always necessary to go through this process to create an object. To create a single uninitialized object, you can, instead, just call CoCreateInstance.

You have viewed 1 page out of 66. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

# COM DCOM Interview Questions and Answers :: ALL Interview .com
# COM DCOM - COM DCOM Interview Questions
# COM interview questions | TechInterviews
# COM Interview Questions - CodeProject
# Com Dcom Interview Questions - Com and Dcom in Asp Net
# ATL Interview Questions and Answers :: ALL Interview .com
# ActiveX Interview Questions and Answers :: ALL Interview .com

* #1 webmaster Tue 29 Apr/2014 03:43:26(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.