【发布时间】:2021-05-22 21:42:37
【问题描述】:
我尝试使用用 C++ 编写的 dll。它有这个功能:
bool PMDllWrapperClass::GetDeviceList(DEVICE** pDeviceArray, int* nDeviceCount, LAN_DEVICE** pLanDeviceArray, int LanDeviceCount, int InterfaceTypeToSearch)
我试过了:
cP = ctypes.POINTER(ctypes.POINTER(ctypes.c_int64))
cIP = ctypes.POINTER(ctypes.c_int32)
cLP = ctypes.POINTER(ctypes.c_int32)
cDC = ctypes.c_int32()
cIS = ctypes.c_int32()
resultgetdev = PMDll.GetDeviceList(cP, cIP, cLP, cDC, cIS)
但它说:
ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected LP_LP_c_long instance instead of _ctypes.PyCPointerType
我也尝试过使用双指针,但没有奏效。我可以用 ctypes 解决它还是不可能的?
【问题讨论】:
-
DEVICE和LAN_DEVICE的定义是什么?您还需要传递类型的 instances 而不是 types 并且应该声明.argtypes和.restype。ctypes也只能理解C接口,所以GetDeviceList函数必须是extern "C"。
标签: python dll arguments ctypes