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
-
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:
assume that a full or a relative (to the current working directory) path is specified, then
use
ctypes.util.find_library()
, thensearch
sys.path
, thensearch
os.environ['PATH']
.
If loading a COM library, path may either be the
ProgID (e.g.,
InternetExplorer.Application
), or theCLSID (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
cdll \(\rightarrow\)
CDLL
windll \(\rightarrow\)
WinDLL
oledll \(\rightarrow\)
OleDLL
net or clr \(\rightarrow\) all keyword arguments are ignored
java \(\rightarrow\)
JavaGateway
com \(\rightarrow\) comtypes.CreateObject
activex \(\rightarrow\)
Application.load
- 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 callrun()
).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 returnsNone
.
- 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.