1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// Construct a VT_BSTR VARIANT from a const _bstr_t&
//
inline _variant_t::_variant_t(const _bstr_t& bstrSrc)
{
V_VT(this) = VT_BSTR;
BSTR bstr = static_cast<wchar_t*>(bstrSrc);
if (bstr == NULL) {
V_BSTR(this) = NULL;
}
else {
V_BSTR(this) = ::SysAllocStringByteLen(reinterpret_cast<char*>(bstr),
::SysStringByteLen(bstr));
if (V_BSTR(this) == NULL) {
_com_issue_error(E_OUTOFMEMORY);
}
}
}
// Construct a VT_BSTR VARIANT from a const wchar_t*
//
inline _variant_t::_variant_t(const wchar_t* pSrc)
{
V_VT(this) = VT_BSTR;
V_BSTR(this) = ::SysAllocString(pSrc);
if (V_BSTR(this) == NULL && pSrc != NULL) {
_com_issue_error(E_OUTOFMEMORY);
}
}
// Construct a VT_BSTR VARIANT from a const char*
//
inline _variant_t::_variant_t(const char* pSrc)
{
V_VT(this) = VT_BSTR;
V_BSTR(this) = _com_util::ConvertStringToBSTR(pSrc);
} |