BSTR to std::wstring:
// given BSTR bs
assert(bs != nullptr);
std::wstring ws(bs, SysStringLen(bs));
std::wstring to BSTR:
// given std::wstring ws
assert(!ws.empty());
BSTR bs = SysAllocStringLen(ws.data(), ws.size());
Doc refs:
std::basic_string<typename CharT>::basic_string(const CharT*, size_type)std::basic_string<>::empty() conststd::basic_string<>::data() conststd::basic_string<>::size() constSysStringLen()SysAllocStringLen()