Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > Python与其他语言

c++生成dll使用python调用dll的方法

来源:中文源码网    浏览:201 次    日期:2024-05-18 06:41:57
【下载文档:  c++生成dll使用python调用dll的方法.txt 】


c++生成dll使用python调用dll的方法
第一步,建立一个CPP的DLL工程,然后写如下代码,生成DLL
复制代码 代码如下:#include #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()

相关内容