c++ - ShGetFolderPath wchar_t 不会为 x64 编译

标签 c++ winapi visual-studio-2013

这对 x86 编译良好:

wchar_t localAppData[MAX_PATH]; // Array, not a pointer.
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA, 0, NULL, localAppData);
std::wstringstream ss;
ss << localAppData;
return ss;

这对 x64 编译良好:

char localAppData[MAX_PATH]; // Array, not a pointer.
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA, 0, NULL, localAppData);
std::wstringstream ss;
ss << localAppData;
return ss;

但是,我想找到一个同时适用于 x86 和 x64 的解决方案,这样我就不必在每次切换平台时都切换“localAppData”的声明。

有人知道解决办法吗?

谢谢。

最佳答案

问题是您的 x86 项目配置为 Unicode,但您的 x64 项目配置为多字节。确保字符集在所有配置中保持一致。据推测,您打算自始至终使用 Unicode。

关于c++ - ShGetFolderPath wchar_t 不会为 x64 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32067415/

相关文章:

c++ - 无法写入/proc/<pid>/coredump_filter

c++ - 开罗图书馆和 Cmake

visual-studio-2013 - 我在 Visual Studio 2013 中有一个现有的解决方案。如何将它导入我的 VS Online 工作区?

c++ - 通过 WinAPI 提取字体版本

c++ - 需要更多关于为 '_MSC_VER' 检测到的 LNK2038 不匹配的解释

c++ - Xbox 360 Controller API 不合作

c++ - 继承与组合::我的理解正确吗?

c++ - Apache 点燃 v2.7 : Can't build linux ODBC driver - inline variable compile error

c++ - 如何获取 Windows 控制台高度?

c - 在 while(1) 循环中阻塞的线程内处理 postthreadmessage() 或使用 "Event Driven Sockets"