ctypes.ArgumentError al llamar a funciones de DLL con Python
Estoy usando ctypes para llamar funciones en un archivo DLL de acuerdo con un archivo de descripción que describe los parámetros y retornos de las funciones DLL. Aquí hay una función en esta DLL llamada InitNetwork. A continuación se muestra su descripción:
Function:BOOL InitNetwork(char LocalIP[],char ServerIP[],int LocalDeviceID);
Arguments:LocalIP
ServerIP
LocalDeviceID
Return:Success:TRUE;
Faile:FALSE;
Lo que estoy haciendo en Python es así:
from ctypes import *
import os
#Load Dll:
cppdll = CDLL("C:\\VS_projects\\MusicServer_Flask\\NetServerInterface.dll")
#Get the function:
initnetwork = getattr(cppdll, "?InitNetwork@@YAHQAD0H@Z") # The function can be successfully accessed.
#specify arguments' types:
initnetwork.argtypes = [c_char_p,c_char_p,c_int]
Después de esto, intento:
initnetwork("192.168.1.103", "192.168.1.103", 1111)
Obtener un error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
Si intento esto:
initnetwork(LocalIP = "192.168.1.103", ServerIP = "192.168.1.103", LocalDeviceID = 1111)
Obtendré:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: this function takes at least 3 arguments (0 given)
¿Por qué salen estos errores? ¿Cómo puedo llamar a esta función con éxito? Cualquier sugerencia es apreciada. ¡Gracias por su atención