【发布时间】:2012-04-29 13:19:07
【问题描述】:
我在 Windows 上从 (PROCESSENTRY32) pe32.szExeFile 获得了 WCHAR[MAX_PATH]。以下方法不起作用:
std::string s;
s = pe32.szExeFile; // compile error. cast (const char*) doesnt work either
和
std::string s;
char DefChar = ' ';
WideCharToMultiByte(CP_ACP,0,pe32.szExeFile,-1, ch,260,&DefChar, NULL);
s = pe32.szExeFile;
【问题讨论】:
-
你真的需要
std::string吗?它应该直接转换为std::wstring,如std::wstring s(pe32.szExeFile);