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')
可参考:https://blog.csdn.net/zhou191954/article/details/9194715
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))
可参考:https://www.cnblogs.com/fendou-999/p/3527449.html?utm_source=tuicool&utm_medium=referral
待补充...