MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / BecomeDPIAware

Function BecomeDPIAware

LegacyUpdate/Compat.cpp:27–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25static HMODULE hComctl32 = NULL;
26
27void BecomeDPIAware(void) {
28 // Make the process DPI-aware... hopefully
29 // Windows 10 1703+ per-monitor v2
30 _SetProcessDpiAwarenessContext $SetProcessDpiAwarenessContext = (_SetProcessDpiAwarenessContext)GetProcAddress(LoadLibrary(L"user32.dll"), "SetProcessDpiAwarenessContext");
31 if ($SetProcessDpiAwarenessContext) {
32 $SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
33 return;
34 }
35
36 // Windows 8.1 - 10 1607 per-monitor v1
37 _SetProcessDpiAwareness $SetProcessDpiAwareness = (_SetProcessDpiAwareness)GetProcAddress(LoadLibrary(L"shcore.dll"), "SetProcessDpiAwareness");
38 if ($SetProcessDpiAwareness) {
39 $SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
40 return;
41 }
42
43 // Windows Vista - 8
44 _SetProcessDPIAware $SetProcessDPIAware = (_SetProcessDPIAware)GetProcAddress(LoadLibrary(L"user32.dll"), "SetProcessDPIAware");
45 if ($SetProcessDPIAware) {
46 $SetProcessDPIAware();
47 }
48}
49
50// Handling for SxS contexts (mainly for comctl 6.0)
51void IsolationAwareStart(ULONG_PTR *cookie) {

Callers 1

CreateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected