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





Appreciate your std::wcout answer. But how to convert it to std::string?
– user3635998
Jun 29 at 9:41






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.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined

Opening a url is failing in Swift