A-A+
 VS C++ w_char*(wchar_t*)或CString转char*
在Visual Studio C++中很多函数都需要使用const char字符串作为参数,通过如下方法可以将w_char*(wchar_t*)或CString字符串转换成const char*字符串。
CString str = L"wchar_t to const char";
 int iSize;
 char* pszMultiByte;
 //返回接受字符串所需缓冲区的大小,已经包含字符结尾符'\0'
 iSize = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); //iSize =wcslen(pwsUnicode)+1=6
 pszMultiByte = (char)malloc(iSizesizeof(char)); //不需要 pszMultiByte = (char)malloc(iSizesizeof(char)+1);
 WideCharToMultiByte(CP_ACP, 0, str, -1, pszMultiByte, iSize, NULL, NULL);
pszMultiByte即为转换后的char*字符串。
