aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Windows64
diff options
context:
space:
mode:
authorvoid_17 <61356189+void2012@users.noreply.github.com>2026-03-03 02:20:24 +0700
committerGitHub <noreply@github.com>2026-03-03 03:20:24 +0800
commit5a9e512117da0c94b39b879fe0e282615668ae13 (patch)
tree9b2b77578a58cc3bb33ebddc55bff7e49bd8102b /Minecraft.Client/Windows64
parentbdc8fb5dfa9a111c230d7da5c3790fdb884e818d (diff)
Restore Windows 7 compatibility (#160)
* Call SetProcessDpiAwareness via GetProcAddress to preserve Windows 7 compatibility Shcore.dll and SetProcessDpiAwareness were introduced in Windows 8 and higher, so to keep compatibility with Windows 7, we use GetProcAddress to call this function dynamically, avoiding linker writing binary dependency on shcore.dll in the import table * Revert "Call SetProcessDpiAwareness via GetProcAddress to preserve Windows 7 compatibility" This reverts commit f1f397fdbe64e64ab8f7b5457e8206e9193cece0. * Reapply the fix
Diffstat (limited to 'Minecraft.Client/Windows64')
-rw-r--r--Minecraft.Client/Windows64/Windows64_Minecraft.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
index c2034b8c..e24bc374 100644
--- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
+++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
@@ -707,7 +707,19 @@ void CleanupDevice()
if( g_pd3dDevice ) g_pd3dDevice->Release();
}
-
+typedef HRESULT(__stdcall* SetProcessDpiAwareness_f)(PROCESS_DPI_AWARENESS);
+static HRESULT dyn_SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value)
+{
+ static const auto ptr = reinterpret_cast<SetProcessDpiAwareness_f>(
+ reinterpret_cast<void*>(::GetProcAddress(static_cast<HMODULE>(LoadLibraryExW(L"Shcore.dll", nullptr, 0)), "SetProcessDpiAwareness")));
+ if (ptr == nullptr)
+ {
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return E_NOTIMPL;
+ }
+
+ return ptr(value);
+}
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
@@ -717,7 +729,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
- SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
+ dyn_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);