how to get value from BSTR*
how to get value from BSTR*
I have a BSTR*. how to get the value from the BSTR* to std::string so that I can print it to console?
BSTR* ptr;
HRESULT result = objPtr->GetValue(ptr);
//need to print to console the value
1 Answer
1
std::wcout << ptr;
should work because it is compatible to an wchar_t*.
You can also construct a std::wstring
of an BSTR that is no nullptr
.
std::wstring
nullptr
If you wish to create a std::string
of it you can check outher questions like
this one but be aware of the ideas of encoding. BSTR is encoded as UTF-16.
std::string
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Appreciate your std::wcout answer. But how to convert it to std::string?
– user3635998
Jun 29 at 9:41