我是靠谱客的博主 正直老师,这篇文章主要介绍python 调用 c++ dll 返回的 const char*,现在分享给大家,希望可以做个参考。

C++

为 const char *

#pragma once
#include <iostream>
#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')

最后

以上就是正直老师最近收集整理的关于python 调用 c++ dll 返回的 const char*的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部