Skip to content

Commit 7e9bffa

Browse files
committed
WIN32: Fix GetAwarenessFromDpiAwarenessContext is not supported on win server
1 parent 8029098 commit 7e9bffa

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/pywinbox/_pywinbox_win.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
from ._main import Box
1515

1616

17-
dpiAware = ctypes.windll.user32.GetAwarenessFromDpiAwarenessContext(ctypes.windll.user32.GetThreadDpiAwarenessContext())
17+
try:
18+
dpiAware = ctypes.windll.user32.GetAwarenessFromDpiAwarenessContext(ctypes.windll.user32.GetThreadDpiAwarenessContext())
19+
except AttributeError: # Windows server does not implement GetAwarenessFromDpiAwarenessContext
20+
dpiAware = 0
21+
1822
if dpiAware == 0:
1923
ctypes.windll.shcore.SetProcessDpiAwareness(2)
2024

0 commit comments

Comments
 (0)