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);

转载于:https://www.cnblogs.com/pjl1119/p/6768506.html

你可能感兴趣的:(CString 转换为 wchar_t *)