_com_ptr_t::Attach

Microsoft Specific

Encapsulates a raw interface pointer of this smart pointer's type.

Syntax

void Attach( Interface* pInterface ) throw( );
void Attach( Interface* pInterface, bool fAddRef ) throw( );

Parameters

pInterface
A raw interface pointer.

fAddRef
If it is TRUE, then AddRef is called. If it is FALSE, the _com_ptr_t object takes ownership of the raw interface pointer without calling AddRef.

Remarks

  • Attach( pInterface ) AddRef is not called. The ownership of the interface is passed to this _com_ptr_t object. Release is called to decrement the reference count for the previously encapsulated pointer.

  • Attach( pInterface , fAddRef ) If fAddRef is TRUE, AddRef is called to increment the reference count for the encapsulated interface pointer. If fAddRef is FALSE, this _com_ptr_t object takes ownership of the raw interface pointer without calling AddRef. Release is called to decrement the reference count for the previously encapsulated pointer.

END Microsoft Specific

See also

_com_ptr_t Class