Windows __stdcallยค
Load a 32-bit Windows __stdcall
library in 32-bit Python, see kernel32. Include the "windll"
argument to specify that the calling convention is __stdcall
.
>>> from msl.loadlib import LoadLibrary
>>> kernel = LoadLibrary(r"C:\Windows\SysWOW64\kernel32.dll", "windll")
>>> kernel
<LoadLibrary libtype=WinDLL path=C:\Windows\SysWOW64\kernel32.dll>
>>> kernel.lib
<WinDLL 'C:\Windows\SysWOW64\kernel32.dll', handle ... at ...>
Create an instance of the SYSTEMTIME structure
>>> from ctypes import byref
>>> from msl.examples.loadlib.kernel32 import SystemTime
>>> st = SystemTime()
>>> time = kernel.lib.GetLocalTime(byref(st))
Now that we have a SYSTEMTIME structure we can access its attributes and compare the values to the builtin datetime.datetime module
>>> from datetime import datetime
>>> today = datetime.today()
>>> st.wYear == today.year
True
>>> st.wMonth == today.month
True
>>> st.wDay == today.day
True
See here for an example on how to communicate with kernel32 from 64-bit Python.