CStringT::SetSysString
Reasigna BSTR indicada por pbstr y copia el contenido del objeto de CStringT en él, incluido el carácter de NULL .
BSTR SetSysString(
BSTR* pbstr
) const;
Parámetros
- pbstr
un puntero a una cadena de caracteres.
Valor devuelto
la nueva cadena.
Comentarios
Dependiendo del contenido del objeto de CStringT , el valor de BSTR hace referencia por pbstr puede cambiar. La función produce CMemoryException si existe memoria insuficiente.
Esta función se utiliza normalmente para cambiar el valor de cadenas pasadas por referencia de automatización.
Ejemplo
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);
Requisitos
encabezado: cstringt.h