到目前为止,我已经得到了一个不适用于Python的DLL,并使其与Python工作,返回类型:我只是不能传递参数,因为我做错了,并且我不太理解文档上我应该如何做事情。基本上,我正在测试的DLL中的函数名为“iptouint”。它接受c_char_p并返回c_double。
这是我的代码:
nDll = ctypes.WinDLL('ndll.dll')
nDllProto = ctypes.WINFUNCTYPE(ctypes.c_double)
nDllInit = nDllProto(("dllInit", nDll))
nDllTestProto = ctypes.WINFUNCTYPE(ctypes.c_double,ctypes.c_char_p)
nDllTest = nDllTestProto(("iptouint",nDll),((1, "p1",0),(1, "p2",0)))
#This is the line that throws the error:
print("IP: %s" % nDllTest("12.345.67.890"))
'''
It gives me the error:
ValueError: paramflags must have the same length as argtypes
Im not sure what to do; Ive certainly played around with it to no avail.
Help is much appreciated.
Thanks.
'''