CComBSTR::Attach

void Attach( BSTR src );

Parameters

src

[in] The BSTR to attach to the object.

Remarks

Attaches a BSTR to the CComBSTR object by setting the m_str member to src.

Note   This method will assert if m_str is non-NULL.

Example

//STDMETHOD(BSTRToUpper)(/*[in, out]*/BSTR bstrConv);
STDMETHODIMP CPolyCtl::BSTRToUpper(BSTR bstrConv)
{
   if (bstrConv == NULL) 
      return E_POINTER; 

   // assign bstrConv to m_str member of CComBSTR
   CComBSTR bstrTemp;
   bstrTemp.Attach(bstrConv); 

   // Make string uppercase 
   bstrTemp.ToUpper();

   // set m_str to NULL, so the BSTR is not freed
   bstrTemp.Detach(); 

   return S_OK; 
}

CComBSTR OverviewClass Members

See Also   CComBSTR::Detach, CComBSTR::operator =