一些常见的类型转换

#include <comdef.h>//for BSTR

BSTR bstr_info = get_xxx();//返回BSTR类型

if(!bstr_info)
{
    MessageBox("get_xxx error");
    return;
}

_bstr_t info = bstr_info;//_bstr_t是LPCTSTR  需要上述头文件的支持

CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
pEdit->SetWindowText(info);//这里传入LPCTSTR

 

将wchar_t* 转成 char*

#include <atlconv.h>//for USES_CONVERSION (A2W & W2A宏)

wchar_t* FilePathW = getpath();//宽字符 字符串

USES_CONVERSION;
char* FilePathA =W2A(FilePathW);//字符串
posted @ 2019-01-04 20:46  长老猪  阅读(132)  评论(0编辑  收藏  举报