From ebe7581f62178a333c4ce498c22d9858ee5a3d29 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 2 Aug 2019 11:39:54 -0700 Subject: [PATCH] check for Win7 before using SHCore.dll API --- .../platform/src/platform/backend/WINPlatform.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/platform/src/platform/backend/WINPlatform.cpp b/libraries/platform/src/platform/backend/WINPlatform.cpp index 8c0bb1b9aa..2958374451 100644 --- a/libraries/platform/src/platform/backend/WINPlatform.cpp +++ b/libraries/platform/src/platform/backend/WINPlatform.cpp @@ -27,7 +27,6 @@ #include #pragma comment(lib, "dxgi.lib") #include -#pragma comment(lib, "Shcore.lib") #endif @@ -118,10 +117,19 @@ void WINInstance::enumerateGpusAndDisplays() { // Grab the dpi info for the monitor UINT dpiX{ 0 }; UINT dpiY{ 0 }; - GetDpiForMonitor(outputDesc.Monitor, MDT_RAW_DPI, &dpiX, &dpiY); UINT dpiXScaled{ 0 }; UINT dpiYScaled{ 0 }; - GetDpiForMonitor(outputDesc.Monitor, MDT_EFFECTIVE_DPI, &dpiXScaled, &dpiYScaled); + + // SHCore.dll is not available prior to Windows 8.1 + HMODULE SHCoreDLL = LoadLibraryW(L"SHCore.dll"); + if (SHCoreDLL) { + auto _GetDpiForMonitor = reinterpret_cast(GetProcAddress(SHCoreDLL, "GetDpiForMonitor")); + if (_GetDpiForMonitor) { + _GetDpiForMonitor(outputDesc.Monitor, MDT_RAW_DPI, &dpiX, &dpiY); + _GetDpiForMonitor(outputDesc.Monitor, MDT_EFFECTIVE_DPI, &dpiXScaled, &dpiYScaled); + } + FreeLibrary(SHCoreDLL); + } // Current display mode DEVMODEW devMode;