CComBSTR::Detach

BSTR Detach( );

Return Value

The BSTR associated with the CComBSTR object.

Remarks

Detaches m_str from the CComBSTR object and sets m_str to NULL.

Example

// Method which converts bstrIn to uppercase 
STDMETHODIMP CPolyCtl::BSTRToUpper(BSTR bstrIn, BSTR* pbstrOut)
{ 
   if (bstrIn == NULL || pbstrOut == NULL) 
      return E_POINTER; 

   // Create a temporary copy of bstrIn
   CComBSTR bstrTemp(bstrIn); 

   if (!bstrTemp) 
      return E_OUTOFMEMORY; 

   // Make string uppercase 
   _wcsupr(bstrTemp); 

   // Return m_str member of bstrTemp 
   *pbstrOut = bstrTemp.Detach(); 

   return S_OK; 
}

CComBSTR OverviewClass Members

See Also   CComBSTR::Attach