手机
当前位置:查字典教程网 >脚本专栏 >python >c++生成dll使用python调用dll的方法
c++生成dll使用python调用dll的方法
摘要:第一步,建立一个CPP的DLL工程,然后写如下代码,生成DLL复制代码代码如下:#include#defineDLLEXPORTextern...

第一步,建立一个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()

【c++生成dll使用python调用dll的方法】相关文章:

如何运行Python程序的方法

简单文件操作python 修改文件指定行的方法

python 获取本机ip地址的两个方法

python paramiko实现ssh远程访问的方法

python 测试实现方法

python实现问号表达式(?)的方法

使用python将mdb数据库文件导入postgresql数据库示例

python装饰器使用方法实例

Python中使用中文的方法

用Python的urllib库提交WEB表单

精品推荐
分类导航