1.ValueError: Procedure probably called with too many arguments
可能是约定不同,使用错了调用动态库的方法;
cdecl格式的约定调用
ctypes.cdll.LoadLibrary(‘dllpath’)或者ctypes.CDll(‘dllpath’)
stdcall格式的约定调用
ctypes.windll.LoadLibrary(‘dllpath’)或者ctypes.WinDll(‘dllpath’)
2.指针参数的动态库接口可使用byref及pointer
例如:
c++接口定义(伪代码):ULONG Test(ULONG a, ULONG b, ULONG *c);
Python调用c++dll:
from ctypes import *
dll = CDLL('D:\\PycharmProjects\\untitled1\\Test.dll')
lon = c_ulong(0)
test = dll.Test
test.argtypes = [c_ulong, c_ulong, POINTER(c_ulong)]
test.restype = c_ulong
res = test(0, 167774363, byref(lon))