CComBSTR::CopyTo

Allocates and returns a copy of m_str via the parameter.

HRESULT CopyTo( 
   BSTR* pbstr  
) throw( ); 
HRESULT CopyTo( 
   VARIANT* pvarDest  
) throw( );

Parameters

  • pbstr
    [out] The address of a BSTR in which to return the string allocated by this method.

  • pvarDest
    [out] The address of a VARIANT in which to return the string allocated by this method.

Return Value

A standard HRESULT value indicating the success or failure of the copy.

Remarks

After calling this method, the VARIANT pointed to by pvarDest will be of type VT_BSTR.

Example

CComBSTR m_bstrURL; // BSTR representing a URL 

// get_URL is the get method for the URL property. 
STDMETHOD(get_URL)(BSTR* pstrURL)
{
   // Make a copy of m_bstrURL and return it via pstrURL 
   return m_bstrURL.CopyTo(pstrURL);
}

Requirements

Header: atlbase.h

See Also

Reference

CComBSTR Class

CComBSTR::Copy

CComBSTR::operator =