Skip to content

Commit 361d460

Browse files
authored
[Windows] wchar_t for executable path (#7494)
* getCurrentExePath() * getCurrentExePath() * win32_error removal * getCurrentExeDirFS * tab fix * cleanup * pg path * pg submodule * conflicts * conflicts * fix
1 parent 77b4b10 commit 361d460

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

libs/openFrameworks/utils/ofFileUtils.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,15 +1860,19 @@ fs::path ofFilePath::getCurrentExePath(){
18601860
}
18611861
return path;
18621862
#elif defined(TARGET_WIN32)
1863-
vector<char> executablePath(MAX_PATH);
1864-
DWORD result = ::GetModuleFileNameA(nullptr, &executablePath[0], static_cast<DWORD>(executablePath.size()));
1863+
wchar_t filename[MAX_PATH];
1864+
DWORD result = ::GetModuleFileName(
1865+
nullptr, // retrieve path of current process .EXE
1866+
filename,
1867+
_countof(filename)
1868+
);
18651869
if (result == 0) {
1866-
ofLogError("ofFilePath") << "getCurrentExePath(): couldn't get path, GetModuleFileNameA failed";
1867-
} else {
1868-
return string(executablePath.begin(), executablePath.begin() + result);
1870+
// Error
1871+
ofLogError("ofFilePath") << "getCurrentExePath(): couldn't get path, GetModuleFileName failed";
18691872
}
1873+
return filename;
18701874
#endif
1871-
return "";
1875+
return {};
18721876
}
18731877

18741878

0 commit comments

Comments
 (0)