1. Reference methods
There are two kinds of loading methods on the net, introduce many, no longer repeat
StdCall calling convention
Ctypes.windll.LoadLibrary ("DllPath")
cTYPES. Windll ("DllPath")
CDECL calling convention
Ctypes.cdll.LoadLibrary ("DllPath")
cTYPES. Cdll ("DllPath")
cTYPES data Type C data type
C_char Char
C_short Short
C_int int
C_long Long
C_ulong Unsign Long
C_float float
C_double Double
c_void_p void
The corresponding pointer type is appended with "_p", such as int* is c_int_p and so on.
In Python to implement the structure in C, you need to use classes.
2. Error
The call reported the following error
Enter Q to Quit:dll
Traceback (most recent):
File "G:\000 WORK\10 license plate number \query\test.py", line A, in <module>
Yzm ()
File "G:\000 WORK\10 license plate number \query\test.py", line series, in Yzm
Lm_dll = cTYPES. Windll ("./lm.dll")
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
Self._handle = _dlopen (self._name, mode)
Windowserror: [Error 193]%1 is not a valid Win32
Python is found to be installed in 64 bits, while DLLs are 32 bits. Install 32-bit Python problem resolution
"Python" References C's DLL