From 34533ad4f13a5cec77f449c4b2ca200c54800a10 Mon Sep 17 00:00:00 2001 From: Arvid Gerstmann Date: Fri, 13 Jul 2018 23:41:38 +0200 Subject: [PATCH] Dynamically import GetDpiForSystem, to support older Windows versions --- standalone/src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/standalone/src/main.cpp b/standalone/src/main.cpp index 355f7eb7..6ae6f8aa 100644 --- a/standalone/src/main.cpp +++ b/standalone/src/main.cpp @@ -51,7 +51,13 @@ int main( int argc, char** argv ) float dpiScale = 1.f; #ifdef _WIN32 - dpiScale = GetDpiForSystem() / 96.f; + typedef UINT(*GDFS)(void); + GDFS getDpiForSystem = nullptr; + HMODULE dll = GetModuleHandleW(L"user32.dll"); + if (dll != INVALID_HANDLE_VALUE) + getDpiForSystem = (GDFS)GetProcAddress(dll, "GetDpiForSystem"); + if (getDpiForSystem) + dpiScale = getDpiForSystem() / 96.f; #endif // Setup ImGui binding