到目前爲止我已經得到了一個DLL並不意味着python可以使用它,而類型返回:我只是不能傳遞它的參數,因爲我做錯了,我不太瞭解文檔關於我應該如何做事情。基本上,我測試的DLL中的函數名爲「iptouint」。它需要一個c_char_p並返回一個c_double。python ctypes拋出錯誤?
這裏是我的代碼:
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.
'''
請說出你正在調用的函數在「ndll」dll中調用的函數的名稱和C文檔。 – jsbueno
@jsbueno就像我說過的,該函數被命名爲「iptouint」並接受一個double並返回一個字符串。 – pajm