HELLO,
I have a doubt in COM.
Addref function adds the number of objects
If I call release once ,will it be safe .
can anyone tell me abt this concept ?
HELLO,
I have a doubt in COM.
Addref function adds the number of objects
If I call release once ,will it be safe .
can anyone tell me abt this concept ?
Release must be called for each COM object you construct yourself. So the answer is not if you only call Release once for more than one object.
While you're breakin' down my back n'
I been rackin' out my brain
It don't matter how we make it
'Cause it always ends the same
You can push it for more mileage
But your flaps r' wearin' thin
And I could sleep on it 'til mornin'
But this nightmare never ends
Don't forget to call my lawyers
With ridiculous demands
An you can take the pity so far
But it's more than I can stand
'Cause this couchtrip's gettin' older
Tell me how long has it been
'Cause 5 years is forever
An you haven't grown up yet
-- You Could Be Mine - Guns N' Roses
Thanks for the information...
Is there any way to locate in the
memory where these objects gets added up and released...
Or any tools that is easy to use for a beginner like me..
COM keeps track of it for you internally. Why I don't know. Microsoft's Visual C++ 6.0 and .Net have wizards that help you with COM and ATL to build services and programs.
While you're breakin' down my back n'
I been rackin' out my brain
It don't matter how we make it
'Cause it always ends the same
You can push it for more mileage
But your flaps r' wearin' thin
And I could sleep on it 'til mornin'
But this nightmare never ends
Don't forget to call my lawyers
With ridiculous demands
An you can take the pity so far
But it's more than I can stand
'Cause this couchtrip's gettin' older
Tell me how long has it been
'Cause 5 years is forever
An you haven't grown up yet
-- You Could Be Mine - Guns N' Roses
The reason is that a COM object may be referenced by more than 1 interface.Originally posted by velius
COM keeps track of it for you internally. Why I don't know.
IE; The first reference to CMyComObj2 might come from some sort of object factory via IUnknown (the interface that gives the AddRef & Release virtual funcs). You might then use QueryInterface (also from IUnknown) to get the IMyComObj interface (allowing you to use the object's member funcs)...and leter use QueryInterface again to get access to IMyComObj2 to get access to extra more recent facilities avaialable.
Now you have 3 interfaces, but 1 object. So if I deleted the object before all interfaces were done I would face a nasty crash. So Com's reference counting allows you to free an interface when your done without worrying if the object has been destroyed as a result
Thanks for that explanation. I barely know COM. The newer DirectX SDK is driven by COM so I needed to learn something about it. That was something I guess I must have forgoten about.
While you're breakin' down my back n'
I been rackin' out my brain
It don't matter how we make it
'Cause it always ends the same
You can push it for more mileage
But your flaps r' wearin' thin
And I could sleep on it 'til mornin'
But this nightmare never ends
Don't forget to call my lawyers
With ridiculous demands
An you can take the pity so far
But it's more than I can stand
'Cause this couchtrip's gettin' older
Tell me how long has it been
'Cause 5 years is forever
An you haven't grown up yet
-- You Could Be Mine - Guns N' Roses
If you are using it for DX, then there's not too much you need to know about......some info on reference counting and using QueryInterface might indeed be useful, knowledge of GUIDS and what they do, and being happy to use interfaces......have that it you shouldnt be too bothered.
Com can get a little complex when you start creating components yourself.....lot's messing around with the registry, using the IDL (Interface Definition Language), Mutlithreading concerns, Dual Interfaces, Aggregation and object factories........that's where ATL becomes very usfull for Com as it uses wizards, macros & templates to shield you from the bare nastiness of writing a Com component.