diff --git a/lib/utils/Utils.cpp b/lib/utils/Utils.cpp index e053526d0..eb70afdb3 100644 --- a/lib/utils/Utils.cpp +++ b/lib/utils/Utils.cpp @@ -125,10 +125,15 @@ namespace MAT_NS_BEGIN { std::string GetTempDirectory() { #ifdef _WIN32 + auto lpGetTempPathW = reinterpret_cast(GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetTempPath2W")); + if (lpGetTempPathW == NULL) + { + lpGetTempPathW = ::GetTempPathW; + } /* UTF-8 temp directory for Win32 Desktop apps */ std::string path = ""; wchar_t lpTempPathBuffer[MAX_PATH + 1] = { 0 }; - if (::GetTempPathW(MAX_PATH, lpTempPathBuffer)) + if (lpGetTempPathW(MAX_PATH, lpTempPathBuffer)) { path = to_utf8_string(lpTempPathBuffer); }