diff --git a/libraries/ZWidget/src/window/win32/win32window.cpp b/libraries/ZWidget/src/window/win32/win32window.cpp index 64d4701ed5..3ba21698ab 100644 --- a/libraries/ZWidget/src/window/win32/win32window.cpp +++ b/libraries/ZWidget/src/window/win32/win32window.cpp @@ -275,10 +275,12 @@ typedef UINT(WINAPI* GetDpiForWindow_t)(HWND); double Win32Window::GetDpiScale() const { static GetDpiForWindow_t pGetDpiForWindow = nullptr; - if (!pGetDpiForWindow) + static bool done = false; + if (!done) { - HMODULE hMod = LoadLibrary(TEXT("User32.dll")); - pGetDpiForWindow = reinterpret_cast(GetProcAddress(hMod, "GetDpiForWindow")); + HMODULE hMod = GetModuleHandleA("User32.dll"); + if (hMod != nullptr) pGetDpiForWindow = reinterpret_cast(GetProcAddress(hMod, "GetDpiForWindow")); + done = true; } if (pGetDpiForWindow)