#include <atlstr.h>
LPCWSTR stringToLPCWSTR(std::string orig)
{
size_t origsize = orig.length() + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t* wcstring = new wchar_t[sizeof(wchar_t) * (orig.length() - 1)];
mbstowcs_s(&convertedChars, wcstring, origsize, orig.c_str(), _TRUNCATE);
return wcstring;
}
22. std::string 转为LPWSTR
于 2024-03-11 18:24:17 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)