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')
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐