2011-04-18 23:27:55|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:C/C++, MFC, 字符处理|来源:唯设编程网
_bstr_t与CString相互转换
_bstr_t bstr; CString strSql; CString -> _bstr_t: bstr = (_bstr_t)strSql; _bstr_t -> CString: strSql = (LPCSTR)bstr;
BSTR宽字符串与CString相互转换
BSTR bstr; CString strSql; CString -> BSTR: bstr = strSql.AllocSysString(); BSTR -> CString: strSql = (LPCSTR)bstr;
_variant_t 类型说明
(1)、一般传给这3个指针的值都不是MFC直接支持的数据类型,而要用_variant_t转换一下
_variant_t(XX)可以把大多数类型的变量转换成适合的类型传入:
(2)、_variant_t 与其他类型之间转换
_variant_t var;
_variant_t -> long:(long)var;
_variant_t -> CString: CString strValue = (LPCSTR)_bstr_t(var);
CString -> _variant_t: _variant_t(strSql);