CString 转换为 wchar_t *

1、将CString转换为const char*

CString str = _T("231222");

std::string strDp = CStringA(str);  //或: std::string strDp = CT2A(str, CP_ACP);

2、将const char*转换为wchar_t*类型

size_t len = strDp.length() + 1;
size_t converted = 0;
wchar_t * WStr = (wchar_t*)malloc(len * sizeof(wchar_t));
mbstowcs_s(&converted, WStr, len, strDp.c_str(), _TRUNCATE);

上一篇:API使用


下一篇:记CRenderTarget:DrawText()绘制中文乱码的BUG及解决办法