void Cstring2Char(CString src, char* dst)
{
DWORD dwMinSize;
dwMinSize = WideCharToMultiByte(CP_ACP, NULL, src, -1, NULL, 0, NULL, FALSE);
char * pp = new char[dwMinSize];
WideCharToMultiByte(CP_OEMCP, NULL, src, -1, pp, dwMinSize, NULL, FALSE);
strcpy(dst, pp);
delete[] pp;
}
调用方法:
/* 一个全局的变量 CString m_strValue; 转化出来的结果存放在buffer里面 */
char buffer[1024] = {0};
Cstring2Char(m_strValue, buffer);