Examples

A lot of code, which was written with ctypescdll, windll or oledll in mind and which runs under Windows, should run just fine with zugbruecke on Unix.

import zugbruecke as ctypes

simple_demo_routine = ctypes.windll.LoadLibrary('demo_dll.dll').simple_demo_routine
simple_demo_routine.argtypes = (ctypes.c_float, ctypes.c_float)
simple_demo_routine.restype = ctypes.c_float
return_value = simple_demo_routine(20.0, 1.07)
print('Got "%f".' % return_value)

It will print Got "1.308412". assuming that the corresponding routine in the DLL looks somewhat like this:

float __stdcall __declspec(dllimport) simple_demo_routine(float param_a, float param_b)
{ return param_a - (param_a / param_b); }

Because of the drop-in replacement design of zugbruecke, it is possible to write Python code which works under both Unices and Windows.

from sys import platform
if any([platform.startswith(os_name) for os_name in ['linux', 'darwin', 'freebsd']]):
        import zugbruecke as ctypes
elif platform.startswith('win'):
        import ctypes
else:
        # Handle unsupported platforms

For more examples check the examples directory of this project. For an overview over its entire range of capabilities have a look at zugbruecke’s test suite. For the full demo DLL source code check the demo_dll directory of this project.

Please also consult the documentation of ctypes.