Python 蟒蛇3;ctypes;对于数组指针

Python 蟒蛇3;ctypes;对于数组指针,python,pointers,dll,ctypes,Python,Pointers,Dll,Ctypes,我想通过ctypes模块调用一个函数(AES_crypt),该函数来自xx.dll,这是我的代码(python 3.6.1): C函数的原型是: AES_crypt( UINT32 *dataout, UINT32 *datain, UINT32 block_len, UINT32 *iv, UINT32 *ks,

我想通过ctypes模块调用一个函数(AES_crypt),该函数来自xx.dll,这是我的代码(python 3.6.1):

C函数的原型是:

AES_crypt(
               UINT32 *dataout,
               UINT32 *datain, 
               UINT32 block_len, 
               UINT32 *iv, 
               UINT32 *ks,
               UINT32 *para,
               UINT32 enc_dec_sel,
               UINT32 ecb_cbc_sel
              );
但是,调试信息是:

Traceback (most recent call last):
File "D:\Project\python\aes_vs\aes_vs\aes_vs.py", line 113, in 
<module>
AES_ECB_MODE
ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected LP_c_ulong 
instance instead of pointer to LP_c_ulong
回溯(最近一次呼叫最后一次):
文件“D:\Project\python\aes\u vs\aes\u vs\aes\u vs.py”,第113行,在
AES_ECB_模式
ctypes.ArgumentError:参数1::应为LP_c_ulong
实例,而不是指向LP_c_ulong的指针
我想知道为什么,我能做什么?
谢谢大家!

数组作为指向第一个元素的指针传递。您的函数应该是
tuple2array
,没有
cast
指向指针。传递数组(不是指针)时,
byref
不会引起问题,但实际上是冗余的。把阵列传过去,谢谢。我注释了outcode:cnum=cast(c_编号,指针(c_ulong)),但是,我的调试器意外终止。我被惊呆了。如果您注释掉了定义
cnum
的行,那么您的函数返回什么?它应该返回
c\u number
数组。是的,您是对的,返回的值是
c\u number
而不是
c\u num
,但是,我的调试器意外终止,我被惊呆了。我想知道是否还有其他选择?
Traceback (most recent call last):
File "D:\Project\python\aes_vs\aes_vs\aes_vs.py", line 113, in 
<module>
AES_ECB_MODE
ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected LP_c_ulong 
instance instead of pointer to LP_c_ulong