Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Associa BSTRoggetto CComBSTR impostando il membro m_stra src.
void Attach(
BSTR src
) throw( );
Parametri
- src
[in] BSTR da associare all'oggetto.
Note
Non passare una stringa di caratteri estesi comune a questo metodo.Il compilatore non può intercettare l'errore e gli errori di runtime si verificano.
[!NOTA]
Questo metodo asserirà se m_str non èNULL.
Esempio
// STDMETHOD(BSTRToUpper)(/*[in, out]*/ BSTR bstrConv);
STDMETHODIMP InplaceBSTRToUpper(BSTR bstrConv)
{
// Assign bstrConv to m_str member of CComBSTR
CComBSTR bstrTemp;
bstrTemp.Attach(bstrConv);
// Make sure BSTR is not NULL string
if (!bstrTemp)
return E_POINTER;
// Make string uppercase
HRESULT hr;
hr = bstrTemp.ToUpper();
if (hr != S_OK)
return hr;
// Set m_str to NULL, so the BSTR is not freed
bstrTemp.Detach();
return S_OK;
}
Requisiti
Header: atlbase.h