CStringT::SetSysString

다시 할당 된 BSTR 가리키는 pbstr 의 내용을 복사 하 고는 CStringT 라는 개체를 포함 하 여는 NULL 문자.

BSTR SetSysString(
   BSTR* pbstr
) const;

매개 변수

  • pbstr
    문자열에 대 한 포인터입니다.

반환 값

새 문자열입니다.

설명

내용에 따라는 CStringT 의 값, 개체는 BSTR 에서 참조 된 pbstr 변경할 수 있습니다.Throw 함수는 CMemoryException 메모리가 부족 하 여 존재 하는 경우.

이 함수는 일반적으로 자동화에 대 한 참조로 전달 되는 문자열의 값을 변경 하려면 사용 됩니다.

예제

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

요구 사항

헤더: cstringt.h

참고 항목

참조

CStringT 클래스

CMemoryException 클래스