c++生成dll使用python调用dll的方法
程序员文章站
2022-08-14 09:05:46
第一步,建立一个cpp的dll工程,然后写如下代码,生成dll
复制代码 代码如下:#include &...
第一步,建立一个cpp的dll工程,然后写如下代码,生成dll
复制代码 代码如下:
#include <stdio.h>
#define dllexport extern "c" __declspec(dllexport)
dllexport int __stdcall hello()
{
printf("hello world!\n");
return 0;
}
第二步,编写一个 python 文件:
复制代码 代码如下:
# coding: utf-8
import os
import ctypes
cur_path = os.path.dirname(__file__)
if __name__ == '__main__':
print 'starting...'
dll = ctypes.windll(os.path.join(cur_path, 'hello.dll'))
dll.hello()
上一篇: 【大数据】SparkSql 连接查询中的谓词下推处理 (二)
下一篇: 大数据学习路线