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 ...>
>>> from ctypes import pointer
>>> from msl.examples.loadlib.kernel32 import SystemTime
>>> st = SystemTime()
>>> time = kernel.lib.GetLocalTime(pointer(st))
Now that we have a SYSTEMTIME structure we can access its attributes
>>> 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.