赞
踩
1.BSTR -> std::string 举例如下
BSTR bstrTest = ::SysAllocString(L”Test”);
_bstr_t bstr_t(bstrTest);
std::strStl = bstr_t;
SysFreeString(bstrTest );
2.std::string -> BSTR 举例如下
std::string name = "helloworld";
_bstr_t bstr_t(name.c_str());
BSTR ret_val = bstr_t.GetBSTR();
3.CString->std::string 举例如下:
CString strMfc=“test“;
std::string strStl;
#ifdef _UNICODE
USES_CONVERSION
strStl=W2A(strMfc.LockBuffer());
strMfc.UnlockBuffer();
#else
strStl = strMfc.GetBuffer(0);
strMfc.ReleaseBuffer();
#endif
4.std::string->CString 举例如下:
CString strMfc;
std::string strStl=“test“;
strMfc=strStl.c_str();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。