Skip to content

Commit

Permalink
[logutil.py] Use WinDLL instead of windll (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
moi15moi authored Jan 25, 2025
1 parent b69e922 commit f85ef39
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions comtypes/logutil.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# logutil.py
import logging, ctypes
import logging
from ctypes import WinDLL
from ctypes.wintypes import LPCSTR, LPCWSTR

_kernel32 = WinDLL("kernel32")

_OutputDebugStringA = _kernel32.OutputDebugStringA
_OutputDebugStringA.argtypes = [LPCSTR]
_OutputDebugStringA.restype = None

_OutputDebugStringW = _kernel32.OutputDebugStringW
_OutputDebugStringW.argtypes = [LPCWSTR]
_OutputDebugStringW.restype = None


class NTDebugHandler(logging.Handler):
def emit(
self,
record,
writeA=ctypes.windll.kernel32.OutputDebugStringA,
writeW=ctypes.windll.kernel32.OutputDebugStringW,
writeA=_OutputDebugStringA,
writeW=_OutputDebugStringW,
):
text = self.format(record)
if isinstance(text, str):
Expand Down

0 comments on commit f85ef39

Please sign in to comment.