的數據類型應在此stringUpcase函數中使用我的DLL文件導入C DLL函數
void __cdecl stringUpcase(char IN_str[], char OUT_str[], int32_t len);
我在Python 3.6試圖ctype.c_char_p和這個函數應該返回大寫字符串「 HELO「在OUT_str變量中。
dl = ctypes.cdll.LoadLibrary("path/of/dll/file.dll")
IN_str = 'helo'
OUT_str = ''
IN_len = len(IN_str)
dl.stringUpcase.restype = ctypes.c_void_p
dl.stringUpcase.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int32]
dl.stringUpcase(IN_str, OUT_str, IN_len);
控制檯錯誤輸出
line 21, in <module>
dl.stringUpcase(IN_str, OUT_str, IN_len);
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
感謝您的幫助,您可以提供。
'strCnt'或'stringUpcase'? – purplepsycho
對不起我的錯誤...它是** stringUpcase **函數 –