如何在C ++(Unicode)中将std :: string转换为LPCWSTR

我正在寻找将std :: string转换为LPCWSTR的方法或代码段



繁华开满天机
浏览 972回答 3
3回答

梵蒂冈之花

std::wstring s2ws(const std::string& s){    int len;    int slength = (int)s.length() + 1;    len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);     wchar_t* buf = new wchar_t[len];    MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);    std::wstring r(buf);    delete[] buf;    return r;}std::wstring stemp = s2ws(myString);LPCWSTR result = stemp.c_str();
打开App,查看更多内容
随时随地看视频慕课网APP