这是我找到的一个方案:
CString str = "A string here" ;
LPWSTR lpszW = new WCHAR[255];//这个255可以根据CString的长度来确定。比如使用下面的nLen
LPTSTR lpStr = str.GetBuffer( str.GetLength() );
int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lpStr, -1, lpszW, nLen);
//在此使用转化后的WCHAR*
//最后不要忘了删除
delete[] lpszW;
本文介绍了一种将CString转换为WCHAR*的方法。通过使用MultiByteToWideChar函数完成转换,并详细展示了转换过程中的每一步操作。这种方法适用于需要在不同字符集间进行转换的场景。
1513

被折叠的 条评论
为什么被折叠?



