Как задать количество аргументов?
Как задать задавать параметры функции в dll?
class OType(ctypes.Structure):
_fields_ = [("H", ctypes.c_int), # H - word
("M", ctypes.c_byte), # M - classtype
("T", ctypes.c_byte)] # T - byte
dllDS1 = ctypes.windll.LoadLibrary("C:\P10\DatServ1.dll")
funcLF = getattr(dllDS1, "SysLFInitOpen")
print(dllDS1)
# print(funcLF)
wspath = "C:\P10\dicnts.WS"
# LFfunc = dllDS1.SysLFInitOpen
p = ctypes.create_string_buffer(str.encode(wspath, encoding=locale.getpreferredencoding()))
if p is None:
print('Не удалось перевести в byte-представление: ', wspath)
funcLF.restype = ctypes.c_int
funcLF.argtypes = [p, ctypes.POINTER(OType)]
handle = funcLF()
if handle is None:
print('Не удалось загрузить файл: ', wspath)
print(handle)
Пока все бьется в строчку
funcLF.argtypes = [p, ctypes.POINTER(OType)]
и выдает ошибку
<WinDLL 'C:\P10\DatServ1.dll', handle 2de0000 at 0xbede68>
Traceback (most recent call last):
File "C:\P10\app_24_project\dllkerneltest.py", line 26, in
funcLF.argtypes = [p, ctypes.POINTER(OType)]
TypeError: item 1 in argtypes has no from_param method
Функции самой dll видны, но подозрения упали на то, что нужно задать количество аргументов внутри параметра.