std::string BSTR 互相转化


 

BSTR转化为std::string
#include

// this is the BSTR
BSTR Bstr = ::SysAllocString(L"Hello World");  

// covert to std::string
_bstr_t bstr_t(Bstr);
std::string str(bstr_t);


// free the BSTR
::SysFreeString(Bstr);
std::string to BSTR
2008-03-18 13:20

    std::string name = "ni hao me";

    _bstr_t bstr_t(name.c_str());//取name的字符串形式

    BSTR ret_val = bstr_t.GetBSTR(); //得到BSTR

你可能感兴趣的:(string)