Calling dll in python 3 with LPSTR -
i have .dll named my.dll, 4 functions, called in python 3.5 using:
mydll = ctypes.cdll.loadlibrary(path:\to\my.dll)
my problem calling function has lpstr:
#include "stdafx.h" #include "newheader.h" double _stdcall pain_function(double arg1, double arg2, lpstr arg_string_with_spaces) the other 3 calls my.dll work fine.
below code tried pain_function:
import ctypes ctypes import wintypes # load dll mydll = ctypes.windll(path:\to\my.dll) # call function pain_function = mydll.pain_function # typecast arguments pain_function.argtypes = [ctypes.c_double, ctypes.c_double, wintypes.lpstr] # typecast return pain_function.restype = ctypes.c_double pain_return = pain_function(arg1, arg2, some_string) pain_return returns nonsensical number. tried variations, along lines of:
some_string = ctypes.create_string_buffer(b' ' * 200) i have looked here among other places:
what correct way pass string of 200 spaces dll?
thank in advance
you indicated prototype was:
double _stdcall pain_function(double arg1, double arg2, lpstr arg_string_with_spaces) but using:
mydll = ctypes.cdll.loadlibrary(path:\to\my.dll) it should be, __stdcall calling convention:
mydll = ctypes.windll('path:\to\my.dll')
Comments
Post a Comment