LPCWSTR stringToLpcwstr(const std::string& orig)
{
int len;
int slength = orig.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, orig.c_str(), slength, 0, 0);
wchar_t * buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, orig.c_str(), slength, buf, len);
// 转为栈区
std::wstring r(buf);
// 防止内存泄漏
delete[] buf;
buf = nullptr;
return r.c_str();
}
std::string to LPCWSTR
最新推荐文章于 2024-05-24 15:31:50 发布
2837

被折叠的 条评论
为什么被折叠?



