char*与CString的转换
CString MCharToCString(char* szChar)
{
CString strValue;
int nLen=0;
nLen= MultiByteToWideChar(CP_ACP, 0, szChar, -1, NULL, 0);
WCHAR wBuf[1024];
MultiByteToWideChar(CP_ACP, 0, szChar, -1, wBuf, nLen);
strValue.Format(_T("%s"),wBuf);
return strValue;
}
CString与char*的转换 char* CStringToMChar(CString str)
{
char szChar[1024];
int nlen=0;
memset(szChar,0x00,1024);
nlen=WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, str, -1, szChar, nlen, NULL, NULL);
return szChar;
}
{
CString strValue;
int nLen=0;
nLen= MultiByteToWideChar(CP_ACP, 0, szChar, -1, NULL, 0);
WCHAR wBuf[1024];
MultiByteToWideChar(CP_ACP, 0, szChar, -1, wBuf, nLen);
strValue.Format(_T("%s"),wBuf);
return strValue;
}
CString与char*的转换 char* CStringToMChar(CString str)
{
char szChar[1024];
int nlen=0;
memset(szChar,0x00,1024);
nlen=WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, str, -1, szChar, nlen, NULL, NULL);
return szChar;
}