BSTR DoSOmething()
{
return L"";
}
OR is it okay to pass TCHAR * to API taking BSTR as input parameter.
Is it okay to convert wchar_t string into BSTR via a return statement.Will it cause some memory corruption?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it is not OK because some APIs expect not just a
WCHAR*pointer, whichBSTRalso is, but a realBSTRpointer with length information attached. Still casting this way might often work out well, and this might be misleading.Everything about BSTRs: Eric’s Complete Guide To BSTR Semantics.
A related quote from there: