-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkernel32.py
More file actions
23 lines (17 loc) · 858 Bytes
/
Copy pathkernel32.py
File metadata and controls
23 lines (17 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from ctypes import WinDLL, wintypes
from ..exceptions import SystemApiError
__all__ = ["Kernel32"]
class Kernel32():
def __init__(self) -> None:
kernel32 = WinDLL("kernel32")
self.LOCALE_NAME_MAX_LENGTH = 85
# https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename
self.GetUserDefaultLocaleName = kernel32.GetUserDefaultLocaleName
self.GetUserDefaultLocaleName.restype = wintypes.INT
self.GetUserDefaultLocaleName.argtypes = [wintypes.LPWSTR, wintypes.INT]
self.GetUserDefaultLocaleName.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