/*
* 函数名: CString2Char
* 参数1: CString str 待转换字符串
* 参数2: char ch[] 转换后将要储存的位置
* 将Unicode下的CString转换为char*
*/
void CString2Char(CString str, char ch[])
{
int i;
char *tmpch;
int wLen = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);//得到Char的长度
tmpch = new char[wLen + 1]; //分配变量的地址大小
WideCharToMultiByte(CP_ACP, 0, str, -1, tmpch, wLen, NULL, NULL); //将CString转换成char*

for(i = 0; tmpch[i] != '\0'; i++) ch[i] = tmpch[i];
ch[i]
= '\0';
}

 

相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-02-09
  • 2021-10-27
  • 2021-08-30
  • 2022-02-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-12-20
  • 2022-01-06
  • 2021-11-26
相关资源
相似解决方案