0
点赞
收藏
分享

微信扫一扫

const char *转wstring 方法

小猪肥 2022-12-29 阅读 112


直接调用下列方法,输入参数即可转换

wstring InjectDll::charToWstring(const char* szIn)
{
int length = MultiByteToWideChar(CP_ACP, 0, szIn, -1, NULL, 0);
WCHAR* buf = new WCHAR[length + 1];
ZeroMemory(buf, (length + 1) * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szIn, -1, buf, length);
std::wstring strRet(buf);
delete[] buf;
return strRet;
}

 

举报

相关推荐

0 条评论