//WCHAR*转为CHAR*
DWORD lenw = WideCharToMultiByte(CP_ACP, 0, strFilename, -1, NULL, 0, NULL, FALSE);
//分配目标缓存
char *cstr = new char[lenw];
memset(cstr, 0, lenw);
WideCharToMultiByte(CP_ACP, 0, strFilename, -1, cstr, lenw,NULL, FALSE);
//char*转warch*
char *CStr = (char *)malloc(sizeof(char));
int lenc = strlen(CStr);
//获取输出缓存大小
//VC++ 默认使用ANSI,故取第一个参数为CP_ACP
DWORD dBufSize = MultiByteToWideChar(CP_ACP, 0, CStr, lenc, NULL, 0);
wchar_t * WStr = new wchar_t[lenc];
wmemset(WStr, 0, lenc);
MultiByteToWideChar(CP_ACP, 0, (const char *)CStr, lenc, WStr, lenc+1);
WCHAR*到CHAR*与char*转warch*
最新推荐文章于 2021-05-26 19:20:53 发布