【发布时间】:2016-11-22 02:08:09
【问题描述】:
我在一个 dll 文件中有一个 C 函数,定义如下:
myFunction(const int a, long b, void * data, unsigned int * c, unsigned int * d, unsigned long * timestamp)
参数:
[in]: a
[in]: b
[out]: data, which is a pointer to a buffer that is maximum of 8 bytes
[out]: c, points to a buffer that receives data message length
[out]: d, pointer to a buffer which receives a message flag
[out]: timestamp, pointer to a buffer which receives message timestamp
我的python代码如下:
import ctypes
dllhandle = ctypes.WinDLL("dllFile.dll")
a = 1
b = 1738
data = ctypes.c_void_p*8
c = 0
d = 0
timestamp = 0
dllhandle.myFunction(a, b, data, c, d, timestamp)
当我运行我的 python 代码时,我收到以下错误:
ctypes.ArgumentError: argument 3: <type 'exceptions.TypeError'>: Don't know how to convert parameter 3.
我认为这与我创建数据缓冲区指针数组的方式有关。创建数据缓冲区的正确方法是什么?
【问题讨论】:
标签: python python-2.7 dll ctypes