From efcaf17f69a36aade9d08e4108664dcab97b5dc6 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Mon, 5 Feb 2018 10:01:21 +0100 Subject: [PATCH] Make SetExecutablePath() on Windows unicode compatible. --- src/backends/generic/misc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backends/generic/misc.c b/src/backends/generic/misc.c index c5e280cb..973a2cba 100644 --- a/src/backends/generic/misc.c +++ b/src/backends/generic/misc.c @@ -57,8 +57,12 @@ static void SetExecutablePath(char* exePath) // !!! this assumes that exePath can hold PATH_MAX chars !!! #ifdef _WIN32 + WCHAR wexePath[PATH_MAX]; + DWORD len; + + GetModuleFileNameW(NULL, wexePath, PATH_MAX); + len = WideCharToMultiByte(CP_UTF8, 0, wexePath, -1, exePath, PATH_MAX, NULL, NULL); - DWORD len = GetModuleFileNameA(NULL, exePath, PATH_MAX); if(len <= 0 || len == PATH_MAX) { // an error occured, clear exe path