次を使用してpython 3.5で呼び出された、4つの関数を持つ.dll
名前付きのがあります。my.dll
myDLL = ctypes.cdll.LoadLibrary(Path:\to\my.dll)
私の問題は、次の関数を呼び出すことですLPSTR
:
#include "stdafx.h"
#include "newheader.h"
double _stdcall pain_function(double arg1, double arg2, LPSTR arg_string_with_spaces)
他の 3 つの呼び出しは正常にmy.dll
機能します。
以下は、私が試したコードですpain_function
:
import ctypes
from ctypes import wintypes
# Load dll
myDLL = ctypes.WinDLL(Path:\to\my.dll)
# Call function
pain_function = myDLL.pain_function
# Typecast the arguments
pain_function.argtypes = [ctypes.c_double, ctypes.c_double, wintypes.LPSTR]
# Typecast the return
pain_function.restype = ctypes.c_double
pain_return = pain_function(arg1, arg2, some_string)
pain_return
無意味な数値を返します。主に次の行に沿って、いくつかのバリエーションを試しました。
some_string = ctypes.create_string_buffer(b' ' * 200)
私は他の場所の中でもここを見てきました:
200 個のスペースの文字列を dll に渡す正しい方法は何ですか?
前もって感謝します