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.
- Parameters:
path (
str
) –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,
use
ctypes.util.find_library()
to find the shared library file,search
sys.path
, thensearch
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'
.Tip
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
'cdll'
thenCDLL
'windll'
thenWinDLL
'oledll'
thenOleDLL
'net'
or'clr'
then all keyword arguments are ignored'java'
thenJavaGateway
'com'
then comtypes.CreateObject'activex'
thenApplication.load
- Raises:
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.
- property assembly
Returns a reference to the .NET Runtime Assembly object if the shared library is a .NET Framework 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
.
- property lib
Returns the reference to the loaded library object.
For example, if libtype is
- 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.