python 调用 c++ dll 返回的 const char*

python 调用 c++ dll 返回的 const char*,第1张

C++

为 const char *

#pragma once
#include 
#define PYAPI _declspec(dllexport)
extern "C" {
	PYAPI const char* runCapture(char* ip, int port, char* username, char* password, char* channel, int preset, char* type, char* filepath);
}
python
irr = CDLL("./captureWheel_dll.dll")
irr.runCapture.restype = ctypes.c_char_p //定义返回类型
tVersion = irr.runCapture(ip, port, username, password, channel, preset, capturetype, filepath)
s = ""
for i in range(0, len(tVersion)):
    s += chr(tVersion[i])
print('version = ', s)            # 返回值打印为:( version = 1.0)
print("version = ", (tVersion))   # 返回值打印为:( version = b'1.0')

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/569779.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存