您的位置:首页 > 编程语言 > Python开发

python 调用 DLL 的函数,返回的字符串数组的食用方法

2017-04-12 20:16 821 查看

今天需要使用python获得dll的数组,查了一个下午终于找到方法了。

dll的函数:

extern "C" _declspec(dllexport) char*  __stdcall get_string(){
return "hello world!";
}


python代码:

dll = ctypes.windll.LoadLibrary("get_image.dll")
dll.get_string.restype = POINTER(c_ubyte)    //让函数返回ubyte* 类型
p = dll.get_string()
list = []
for n in range(255):
if p
== 0:
break;
list.append(chr(p
))  // ascll转换
list = ''.join(list)
print(list)
quit()


“hello world!”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息