I'm working with a Microsoft Kinect SDK where functions return BSTR. I need to get a QString or std::string.
Here's what I've tried:
BSTR bstr = s->NuiUniqueId();
// QString qs((QChar*)bstr, SysStringLen(bstr));
std::wstring ws(bstr);
ui->lblDetails->setText(QString::fromStdWString(ws));
With this solution the program crashes. With the line that is commented out I get "unresolved external symbol SysStringLen".
Is SysStringLen the way to go, but I need to add some additional libraries (wouldn't the API include it already) or is there another solution?
Additional question: why does Microsoft do it? I mean:
#if !defined(_NATIVE_WCHAR_T_DEFINED)
typedef unsigned short WCHAR;
#else
typedef wchar_t WCHAR;
#endif
typedef WCHAR OLECHAR;
typedef OLECHAR* BSTR;
typedef BSTR* LPBSTR;
What's the reason behind stuff like this? And even if they find it beneficial to use it internally, couldn't they just use normal char array or std::(w)string in the API to make other's life easier?