DXGL r411 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r410‎ | r411 | r412 >
Date:17:17, 15 December 2013
Author:admin
Status:new
Tags:
Comment:
Support "Enabled" setting for DPI scaling.
Modified paths:
  • /cfgmgr/cfgmgr.cpp (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.cpp
@@ -332,8 +332,37 @@
333333 ReadSettings(hKey,cfg,NULL,false,true,NULL);
334334 RegCloseKey(hKey);
335335 hKey = NULL;
 336+ HMODULE hSHCore = NULL;
 337+ HMODULE hUser32 = NULL;
336338 if (initial)
337339 {
 340+ if (cfg->DPIScale == 1)
 341+ {
 342+ bool DPIAwarePM = false;
 343+ hSHCore = LoadLibrary(_T("SHCore.dll"));
 344+ if (hSHCore)
 345+ {
 346+ HRESULT(WINAPI *_SetProcessDpiAwareness)(DWORD value)
 347+ = (HRESULT(WINAPI*)(DWORD))GetProcAddress(hSHCore, "SetProcessDpiAwareness");
 348+ if (_SetProcessDpiAwareness)
 349+ {
 350+ DPIAwarePM = true;
 351+ _SetProcessDpiAwareness(2);
 352+ }
 353+ }
 354+ if (!DPIAwarePM)
 355+ {
 356+ hUser32 = LoadLibrary(_T("User32.dll"));
 357+ if (hUser32)
 358+ {
 359+ BOOL(WINAPI *_SetProcessDPIAware)()
 360+ = (BOOL(WINAPI*)())GetProcAddress(hUser32, "SetProcessDPIAware");
 361+ if (_SetProcessDPIAware) _SetProcessDPIAware();
 362+ }
 363+ }
 364+ if (hSHCore) FreeLibrary(hSHCore);
 365+ if (hUser32) FreeLibrary(hUser32);
 366+ }
338367 HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
339368 BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
340369 if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");