_bstr_t 与 CString 相互转换 ,BSTR 宽字符串与CString相互转换

(1)_bstr_t 与 CString 相互转换

 

_bstr_t bstr;

CString strSql;

CString->_bstr_t: bstr = (_bstr_t) strSql;

_bstr_t->CString: strSql = (LPCSTR) bstr;

 

(2) BSTR 宽字符串与CString相互转换

BSTR bstr;

CString strSql;

CString->BSTR: bstr = strSql.AllocSysString();

BSTR->CString:strSql = (LPCSTR) bstr;

你可能感兴趣的:(_bstr_t 与 CString 相互转换 ,BSTR 宽字符串与CString相互转换)