1
//
tmp1极为CStringW宽字符变量
2 // 转换为psText的char* 变量了
3
4 #ifdef UNICODE
5 DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, tmp1.GetBuffer( 0 ), - 1 , NULL, 0 , NULL, FALSE);
6 char * psText;
7 psText = new char [dwNum];
8 if ( ! psText)
9 delete []psText;
10 WideCharToMultiByte(CP_OEMCP, NULL, tmp1.GetBuffer( 0 ), - 1 , psText, dwNum, NULL, FALSE);
11 #endif
2 // 转换为psText的char* 变量了
3
4 #ifdef UNICODE
5 DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, tmp1.GetBuffer( 0 ), - 1 , NULL, 0 , NULL, FALSE);
6 char * psText;
7 psText = new char [dwNum];
8 if ( ! psText)
9 delete []psText;
10 WideCharToMultiByte(CP_OEMCP, NULL, tmp1.GetBuffer( 0 ), - 1 , psText, dwNum, NULL, FALSE);
11 #endif
注意要加上宏