手机
当前位置:查字典教程网 >脚本专栏 >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 paramiko实现ssh远程访问的方法

使用setup.py安装python包和卸载python包的方法

Python获取当前时间的方法

Python生成随机数的方法

Python 条件判断的缩写方法

python list 合并连接字符串的方法

使用Python进行稳定可靠的文件操作详解

python调用shell的方法

python生成器的使用方法

python中文乱码的解决方法

精品推荐
分类导航