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::LockServer

LockServer() function provides a way for a client to lock the server down in the memory, even if there are actually no active objects in the server.
Called by the client of a class object to keep a server open in memory, allowing instances to be created more quickly.

HRESULT LockServer(
  BOOL fLock
);

Parameter

  • fLock - [in] If TRUE, increments the lock count; if FALSE, decrements the lock count.

Return Values

This method supports the standard COM/DCOM return values E_FAIL, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

  • S_OK - The specified object was either locked ( fLock = TRUE) or unlocked from memory ( fLock = FALSE).

Code without LockServer()

CoGetClassObject call get Factory Interface
 
Factory->CreateInstance(Interface1); /* new allocation */
Interface1->DoOperation1()
Interface1->DoOperation2()
Interface1->Release();/* COM server unloaded */

Factory->CreateInstance(Interface2); /* new allocation */
Interface2->DoOperation1()
Interface2->DoOperation2()
Interface2->Release();/* COM server unloaded */

Factory->CreateInstance(Interface1); /* new allocation */
Interface1->DoOperation1()
Interface1->DoOperation2()
Interface1->Release();/* COM server unloaded */

Factory->CreateInstance(Interface2); /* new allocation */
Interface2->DoOperation1()
Interface2->DoOperation2()
Interface2->Release();/* COM server unloaded */

Code with LockServer()

CoGetClassObject call get Factory Interface
 Factory->LockServer(TRUE);
Factory ->CreateInstance(Interface1); /* new allocation */
Interface1->DoOperation1()
Interface1->DoOperation2()
Interface1->Release(); /* COM object not unloaded */

Factory ->CreateInstance(Interface2); /* new allocation */
Interface2->DoOperation1()
Interface2->DoOperation2()
Interface2->Release();/* COM object not unloaded */

Factory ->CreateInstance(Interface1); /* reuse of object */
Interface1->DoOperation1()
Interface1->DoOperation2()
Interface1->Release();/* COM object not unloaded */

Factory ->CreateInstance(Interface2); /* reuse of object */
Interface2->DoOperation1()
Interface2->DoOperation2()
Interface2->Release();/* COM object not unloaded */
Factory->LockServer(FALSE);
Factory->Release(); 

/* deallocate all objects and server unloaded */

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 18:49:48(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.