use BSTR length to also deal with NULs inside BSTRs correctly in Unicode build

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2008-02-04 08:08:57 +00:00
parent bba85010a3
commit 59af032ab6

View File

@ -80,19 +80,21 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
if ( !bStr )
return wxString();
const int len = SysStringLen(bStr);
#if wxUSE_UNICODE
wxString str(bStr);
wxString str(bStr, len);
#else
wxString str;
const int len = SysStringLen(bStr) + 1;
if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */,
bStr, len,
bStr, len + 1 /* include last NUL */,
wxStringBuffer(str, len), len,
NULL, NULL /* no default char */) )
{
str.clear();
}
#endif
return str;
}