TCHAR->char的转换
CString strData = _T("Hello");int len = WideCharToMultiByte(CP_ACP, 0, strData, -1, NULL, 0, NULL, NULL);char* szTarget = new char[len + 1];memset(szTarget, 0, len + 1);WideCharToMultiByte (CP_ACP, 0,strData, -1, szTarget, len, NULL,NULL);delete[] szTarget;
CString->TCHAR*的转换可以用函数GetBuff()函数原型为:LPTSTR GetBuffer(int nMinBufLength);
CString str("CString");TCHAR* szMsg = new TCHAR[100];//其参数为CString字符串的长度szMsg = str.GetBuffer(str.GetLength());str.ReleaseBuffer();delete []szMsg;szMsg = NUL
TCHAR*->CString的转换
TCHAR szTchar[18] = L"TCHAR";CString str; str.Format(_T("%s"),szTchar);