-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuser32.py
More file actions
24 lines (18 loc) · 910 Bytes
/
Copy pathuser32.py
File metadata and controls
24 lines (18 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from ctypes import WinDLL, wintypes
from ..exceptions import SystemApiError
__all__ = ["User32"]
class User32():
def __init__(self) -> None:
user32 = WinDLL("user32")
self.HWND_BROADCAST = wintypes.HWND(0xFFFF)
self.WM_FONTCHANGE = wintypes.UINT(0x001D)
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendnotifymessagew
self.SendNotifyMessageW = user32.SendNotifyMessageW
self.SendNotifyMessageW.restype = wintypes.BOOL
self.SendNotifyMessageW.argtypes = [wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM]
self.SendNotifyMessageW.errcheck = self.errcheck_is_result_0_or_null
@staticmethod
def errcheck_is_result_0_or_null(result, func, args):
if not result:
raise SystemApiError(f"{func.__name__} fails. The result is {result} which is invalid")
return result