p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

comdeveloper thread: general COM-question

Message #1 by "Jurgen Lisabeth" <jurgenls@s...> on Tue, 20 Feb 2001 16:08:00
I'm writing an COM-object in a in-process server (dll). 

One of its methods is 'Claim'. Purpose of 'Claim' : allow exclusive access 

to a device to the application 

who first called 'Claim' on the object. In this method I set a boolean to 

TRUE (private member of object) 

so I know the first application has claimed it.

I assumed (based on a little COM-knowledge) that when I called the Claim-

method in a second application 

it wouldn't be impossible to Claim it (since boolean = TRUE). Apparently 

I'm mistaken since it's possible 

to claim the device in a second application (boolean = false). 

How does COM handle this situation (what the correct way of working here 

by COM) and how must I handle 


Don't I receive always a same pointer to the requested interface?

Do I have to use shared memory to solve this?

Please Help. Thanks
Message #2 by RFayko@a... on Tue, 20 Feb 2001 12:14:18 EST
It sounds as though you are creating multiple instances. If this DLL is to be 

the sole "gatekeeper" of the resource in question, maybe you should consider 

creating you DLL as a singleton (COM only creates one instance). If you do 

this, you may need to enlist some synchronization features depending upon 

what your resource is used for. There is some examples in the Grime's books 

and in MSDN I believe.


Message #3 by "Nadeem Qazi" <nhqsd@h...> on Tue, 20 Feb 2001 17:38:46 -0000

I u want a variable to be accedd by  all the instance of the object in this 

case claim then u need to make it class variable rather than instance 


Nadeem qazi

  Return to Index