Reallocates the BSTR pointed to by pbstr and copies the contents of the CStringT object into it, including the NULL character.
BSTR SetSysString( BSTR* pbstr ) const;
- A pointer to a character string.
The new string.
Depending on the contents of the CStringT object, the value of the BSTR referenced by pbstr may change. The function throws a CMemoryException if insufficient memory exists.
This function is normally used to change the value of strings passed by reference for Automation.
The following example demonstrates the use of CStringT::SetSysString.
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 > > CAtlString; CAtlString str("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);