BSTR bstrMyBeaster = SysAllocString (L"Tring, Tring!"); WCHAR* pwszMyWCharString = L"Tring, Tring!"; USES_CONVERSION; LPSTR pszCharStringFromBSTR = OLE2A (bstrMyBeaster); LPSTR pszCharStringFromLPWSTR = W2A (pwszMyWCharString); // ... SysFreeString (bstrMyBeaster); > >

I think “USES_CONVERSION;” is very convenient and easy to convert between CComBSTR and Char. But this article also tell us it may happen “Stack overflow” when your source BSTR is over 1MB. The root cause is because use  _alloca.

I think to avoid stack overflow like this,  just use static conversion  not “USE_CONVERSION;”.

Buy Me A Coffee


Attitude is everything