This python code calls a dll(Created in LabVIEW) which returns the size of the string passed as argument. Every time I try passing string with different size, it returns the size as "1". I tried calling the dll in different programming languages like C,LabVIEW, it's working fine.
download link for dll file: https://drive.google.com/open?id=1pnYI6-SfUY3Cn6EeD4mWUO6dlEBH3DmN
import ctypes
from ctypes import windll, cdll,\
c_wchar, c_size_t, c_ulonglong, c_wchar_p, c_void_p,\
sizeof,\
WinError
try:
dllhandle = ctypes.CDLL("Strlen.dll")
print("Library Loaded")
except Exception as e:
print("Can't open DLL:",e)
dllhandle.Strlen.argtypes = [ctypes.c_wchar_p]
dllhandle.Strlen.restype = ctypes.c_int32
data = "Hello"
data_ptr = ctypes.c_wchar_p(data)
print("Data Pointer:",data_ptr)
length = dllhandle.Strlen(data_ptr)
print("Data:",data)
print("String Length:",length)
Can anyone help me solve this?.Thanks in advance.