Condividi tramite


CStringT::SetSysString

Rialloca BSTR puntato da pbstr e copia il contenuto dell'oggetto CStringT in, incluso il carattere NULL.

BSTR SetSysString(
   BSTR* pbstr
) const;

Parametri

  • pbstr
    Un puntatore a una stringa di caratteri.

Valore restituito

La nuova stringa.

Note

In base al contenuto dell'oggetto CStringT, il valore BSTR fatto riferimento da pbstr può cambiare.La funzione genera CMemoryException se la memoria insufficiente esiste.

Questa funzione è generalmente utilizzata per modificare il valore di stringhe passate per riferimento per l'automazione.

Esempio

BSTR bstr = ::SysAllocString(L"Golf is fun!");

// create a CAtlString and change the OLE
// string to the contents of the BSTR
// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;

CAtlString str(_T("Soccer is best!"));
BSTR bstr2 = str.SetSysString(&bstr);

// Now, both bstr and bstr2 reference a single instance of
// the "Soccer" string. The "Golf" string has been freed.
ASSERT(bstr2 == bstr);   

Requisiti

Header: cstringt.h

Vedere anche

Riferimenti

Classe di CStringT

Classe di CMemoryException