C++: Convert wchar_t* to BSTR?

前端 未结 3 851
执念已碎
执念已碎 2021-01-13 05:42

I\'m trying to convert a wchar_t * to BSTR.

#include 
#include 

using namespace std;

int main()
         


        
3条回答
  •  醉酒成梦
    2021-01-13 06:34

    SysStringLen() should only be used on BSTRs allocated by SysAllocString() family functions. Using it as you do will lead to undefined behavior - program can crash or produce unexpected results. Better yet use wrapper classes - ATL::CComBSTR or _bstr_t.

提交回复
热议问题