共用方式為


CComBSTR::Copy

配置和 m_str傳回的複本。

BSTR Copy( ) const throw();

傳回值

m_str 成員的複本。 如果 m_strNULL,傳回 NULL

範例

CComBSTR m_bstrURL;    // BSTR representing a URL 

// put_URL is the put method for the URL property. 
STDMETHOD(put_URL)(BSTR strURL)
{
    ATLTRACE(_T("put_URL\n"));

    // free existing string in m_bstrURL & make a copy  
    // of strURL pointed to by m_bstrURL
    m_bstrURL = strURL;
    return S_OK;
}

// get_URL is the get method for the URL property. 
STDMETHOD(get_URL)(BSTR* pstrURL)
{
    ATLTRACE(_T("get_URL\n"));

    // make a copy of m_bstrURL pointed to by pstrURL
    *pstrURL = m_bstrURL.Copy(); // See CComBSTR::CopyTo 
    return S_OK;
}

需求

Header: atlbase.h

請參閱

參考

CComBSTR 類別

CComBSTR::CopyTo

CComBSTR::operator =