Share via


CStringT::SetSysString

Réaffecte BSTR globale pointe vers pbstr et copie le contenu de l'objet d' CStringT dans ce fichier, y compris le caractère d' NULL .

BSTR SetSysString(
   BSTR* pbstr
) const;

Paramètres

  • pbstr
    Un pointeur vers une chaîne.

Valeur de retour

La chaîne.

Notes

Selon le contenu de l'objet d' CStringT , la valeur d' BSTR référencé par pbstr peut changer.La fonction lève CMemoryException si la mémoire insuffisante existe.

Cette fonction est généralement utilisée pour modifier la valeur des chaînes passés par référence pour l'automation.

Exemple

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);   

Configuration requise

Header: cstringt.h

Voir aussi

Référence

Classe de CStringT

Classe de CMemoryException