1. Load library:
windows:
1
.
import ctypes
dll = ctypes.windll.LoadLibrary( ' test.dll ' )
2 .
import ctypes
dll = ctypes.WinDll( ' test.dll ' )
import ctypes
dll = ctypes.windll.LoadLibrary( ' test.dll ' )
2 .
import ctypes
dll = ctypes.WinDll( ' test.dll ' )
Linux:
1
.
#! /usr/bin/env python
import
ctypes
dll = ctypes.CDLL('./test.so')
NOTE: The functions that in the library need defined as: extern "C" __declspec(export) TYPE __stdcall FUNCTION();
2. Invoke functions:
Windows & Linux:
dll.test();
3. Invoke System (platform) commands:
1
.
import os
import os
str = os.popen("dir").read()
l = str.split("/n")
for a in l:
print a