Passing CComPtr to a function with a prototype raw pointer

I am looking at some inherited C ++ code associated with the Windows Imaging Component library of components, and I noticed the following:

void setProperties(IPropertyBag2* const pBag)
{  
   pBag->Write(...);
}

void other_function()
{
   CComPtr<IPropertyBag2> pBag;
   //Code to initialize pBag
   setProperties(pBag);
}

The method setPropertiessimply writes a bunch of properties to the property package. The code compiles and works fine, because I think it calls the appropriate machine translation operator.

My question is whether such an interface is recommended or is there a better way to pass a pointer. For example, is there any difference (in terms of security / performance) if the signature has been changed to:

void setProperties(const CComPtr<IPropertyBag2>& pBag)
+5
source share
2 answers

- COM. . CComPtr CComPtr.

COM-, , , AddRef Release. , .

CComPtr .

+2

CComPtr ( const ). CComPtr .

, /.

+1
source

All Articles