msl.loadlib.load_library module

Load a shared library.

msl.loadlib.load_library.LibType

The library type.

alias of Literal[‘cdll’, ‘windll’, ‘oledll’, ‘net’, ‘clr’, ‘java’, ‘com’, ‘activex’]

class msl.loadlib.load_library.PathLike

A path-like object.

alias of TypeVar(‘PathLike’, str, bytes, ~os.PathLike)

class msl.loadlib.load_library.LoadLibrary(path, libtype=None, **kwargs)

Bases: object

Load a shared library.

For example, a C/C++, FORTRAN, C#, Java, Delphi, LabVIEW, ActiveX, … library.

Changed in version 0.4: Added support for Java archives.

Changed in version 0.5: Added support for COM libraries.

Changed in version 0.9: Added support for ActiveX libraries.

Parameters:
  • path (PathLike) –

    The path to the shared library.

    The search order for finding the shared library is:

    1. assume that a full or a relative (to the current working directory) path is specified, then

    2. use ctypes.util.find_library(), then

    3. search sys.path, then

    4. search os.environ['PATH'].

    If loading a COM library, path may either be the

    • ProgID (e.g., InternetExplorer.Application), or the

    • CLSID (e.g., {2F7860A2-1473-4D75-827D-6C4E27600CAC}).

  • libtype (LibType | None) –

    The library type.

    The following values are currently supported:

    • cdll: a library that uses the __cdecl calling convention (default)

    • windll or oledll: a library that uses the __stdcall calling convention

    • net: a Microsoft .NET library

    • clr: alias for net (Common Language Runtime)

    • java: a Java archive (.jar or .class files)

    • com: a COM library

    • activex: an ActiveX library

    Tip

    Since the .jar or .class extension uniquely defines a Java library, libtype will automatically be set to java if path ends with .jar or .class.

  • kwargs (Any) –

    All additional keyword arguments are passed to the object that loads the library. If libtype is

Raises:
  • OSError – If the shared library cannot be loaded.

  • ValueError – If the value of libtype is not supported.

property app: Application | None

Returns a reference to the ActiveX main application window.

When an ActiveX library is loaded, the window is not shown (to show it call show()) and the message loop is not running (to run it call run()).

New in version 1.0.

cleanup()

Clean up references to the library.

New in version 0.10.

Return type:

None

property assembly: Any

Returns a reference to the .NET Runtime Assembly object if the shared library is .NET, otherwise returns None.

Tip

The JetBrains dotPeek program can be used to reliably decompile any .NET Assembly into the equivalent source code.

property gateway

Returns the JavaGateway object, only if the shared library is a Java archive, otherwise returns None.

property lib: Any

Returns the reference to the library object.

For example, if libtype is

  • cdll \(\rightarrow\) CDLL

  • windll \(\rightarrow\) WinDLL

  • oledll \(\rightarrow\) OleDLL

  • net or clr \(\rightarrow\) DotNet

  • java \(\rightarrow\) JVMView

  • com or activex \(\rightarrow\) POINTER

property path: str

The path to the shared library file.

class msl.loadlib.load_library.DotNet(items, path)

Bases: object

Contains the namespace modules, classes and System.Type objects of a .NET Assembly.

Do not instantiate this class directly.

Parameters:
  • items (dict) – The items to use to update the internal __dict__ attribute.

  • path (str) – The path to the .NET library file.