If I create the pointer of any COM interface and then assign it to an object of CComPtr
of same COM Interface do I need to release the original COM pointer?
ISomeComInterface* pSomeComInterface = new CSomeComInterfaceImplemented();
CComPtr<ISomeComInterface> cptrSomeComInterface = pSomeComInterface;
// ....
// Do I need to Release original COM Pointer.
pSomeComInterface->Release();
CComPtr
takes care of reference count of its internal interface pointer, managed by the instance of the class. It has no effect on reference counts of other pointers. That is, having assigned the pointer to the variable, you can be sure that CComPtr
's internal pointer is AddRef
'ded and Release
'd as necessary, however you should take care of your raw interface pointer variable pSomeComInterface
yourself and make explicit Release
call.