以下代码
string exePath() {
string path;
char buffer[MAX_PATH];
cout << "reading path\n";
GetModuleFileName(NULL, buffer, MAX_PATH);
string::size_type pos = string(buffer).find_last_of("\\/");
path = string(buffer).substr(0, pos)/*+"\\system.exe"*/;
return path;
}
在 VisualStudio(缓冲区)的第二个参数处给我错误:
类型“char *”参数与类型参数“LPWSTR”不兼容
(从意大利语翻译,我有意大利语的 vs,希望你理解)并且不能在 2 参数中将 Char 转换为 LPWSTR
这段代码可以用 code::blocks 和 dev c++ 很好地编译,但在 vs 中它没有