Skip to content

Kernel64 (Windows __stdcall)¤

Communicate with the kernel32.dll library via the Kernel32 class that is running on a server.

Note

This example is only valid on Windows.

Kernel64 ¤

Kernel64()

Bases: Client64

Communicate with a 32-bit Windows __stdcall library.

This class demonstrates how to communicate with a Windows 32-bit library if an instance of this class is created within a 64-bit Python interpreter.

Source code in src/msl/examples/loadlib/kernel64.py
23
24
25
26
27
28
29
30
31
32
33
def __init__(self) -> None:
    """Communicate with a 32-bit Windows `__stdcall` library, [kernel32.dll]{:target="_blank"}.

    This class demonstrates how to communicate with a Windows 32-bit library if an
    instance of this class is created within a 64-bit Python interpreter.

    [kernel32.dll]: https://www.geoffchappell.com/studies/windows/win32/kernel32/api/
    """
    # specify the name of the corresponding 32-bit server module, kernel32, which hosts
    # the Windows 32-bit library -- kernel32.dll
    super().__init__(module32="kernel32", append_sys_path=Path(__file__).parent)

get_local_time ¤

get_local_time()

Requests kernel32.GetLocalTime function to get the current date and time.

See the corresponding Kernel32.get_local_time method.

Returns:

Type Description
datetime

The current date and time.

Source code in src/msl/examples/loadlib/kernel64.py
35
36
37
38
39
40
41
42
43
44
45
46
def get_local_time(self) -> datetime:
    """Requests [kernel32.GetLocalTime]{:target="_blank"} function to get the current date and time.

    See the corresponding [Kernel32.get_local_time][msl.examples.loadlib.kernel32.Kernel32.get_local_time] method.

    [kernel32.GetLocalTime]: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime

    Returns:
        The current date and time.
    """
    reply: datetime = self.request32("get_local_time")
    return reply