msl.loadlib.load_library module

Load a shared library.

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

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.

  • path (str) –

    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,
    2. use ctypes.util.find_library() to find the shared library file,
    3. search sys.path, then
    4. search os.environ['PATH'] to find the shared library.

    If loading a COM library then path is either the ProgID, e.g. "InternetExplorer.Application", or the CLSID, e.g. "{2F7860A2-1473-4D75-827D-6C4E27600CAC}".

  • libtype (str, optional) –

    The library type. The following values are currently supported:

    • 'cdll' – for a library that uses the __cdecl calling convention
    • 'windll' or 'oledll' – for a __stdcall calling convention
    • 'net' or 'clr' – for Microsoft’s .NET Framework (Common Language Runtime)
    • 'java' – for a Java archive, .jar, or Java byte code, .class, file
    • 'com' – for a COM library
    • 'activex' – for an ActiveX library

    Default is 'cdll'.


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

  • **kwargs

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

    If libtype is

  • OSError – If the shared library cannot be loaded.
  • ValueError – If the value of libtype is not supported.
LIBTYPES = ['cdll', 'windll', 'oledll', 'net', 'clr', 'java', 'com', 'activex']

The library types that are supported.


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


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


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


Returns the reference to the loaded library object.

For example, if libtype is

  • 'cdll' then a CDLL object
  • 'windll' then a WinDLL object
  • 'oledll' then a OleDLL object
  • 'net' or 'clr' then a DotNet object
  • 'java' then a JVMView object
  • 'com' or 'activex' then an interface pointer to the COM object

The path to the shared library file.

class msl.loadlib.load_library.DotNet(dot_net_dict, path)[source]

Bases: object

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

Do not instantiate this class directly.