源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2020-07-20 23:23 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:c++生成dll使用python调用dll的方法
第一步,建立一个CPP的DLL工程,然后写如下代码,生成DLL
[u]复制代码[/u] 代码如下:
#include <stdio.h>     #define DLLEXPORT extern "C" __declspec(dllexport)     DLLEXPORT int __stdcall hello()     {         printf("Hello world!\n");         return 0;     }
第二步,编写一个 python 文件:
[u]复制代码[/u] 代码如下:
# 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()
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部