[英]how to pass char pointer as argument in ctypes python
Please help me in converting below line of c++ code into ctypes python: 请帮我将下面的c ++代码转换成ctypes python:
Ret = openFcn(&Handle, "C:\\Config.xml");
below are the declarations of each: 以下是各自的声明:
typedef uint16_t (* OpenDLLFcnP)(void **, const char *);
OpenDLLFcnP openFcn = NULL;
openFcn = (OpenDLLFcnP) myLibrary.resolve("Open");
void *Handle = NULL;
myLibrary.resolve
is undefined, but the general code you need (untested) is: myLibrary.resolve
未定义,但您需要的常规代码(未经测试)是:
import ctypes
dll = ctypes.CDLL('your.dll')
Open = dll.Open
Open.argtypes = [ctypes.POINTER(ctypes.c_void_p),ctypes.c_char_p]
Open.restype = ctypes.c_uint16
Handle = ctypes.c_void_p()
result = Open(ctypes.byref(Handle),'c:\\Config.xml')
This assumes you have a DLL named your.dll
with a function Open
you want to call. 这假设您有一个名为
your.dll
的DLL, your.dll
包含您要调用的Open
函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.