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
·
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')
更多推荐
已为社区贡献1条内容
所有评论(0)