Linux 拨号vps windows公众号手机端

python如何调用dll库中的函数

lewis 6年前 (2019-04-02) 阅读数 13 #程序编程
文章标签 python

在python中使用ctypes模块调用dll库中函数的方法

1.首先,在Python项目中引入ctypes模块;

from ctypes import *

2.ctypes模块引入后,在Python中加载dll库;

Objdll = ctypes.WinDLL("dllpath")

3.最后,dll库加载好后,通过以下方法即可调用dll库中的函数;

strDllPath = sys.path[0] + str(os.sep) + "createguid.dll"

dll = CDLL(strDllPath)

b = dll.newGUID()

a = c_char_p(b)

except Exception, error:

print error

return ""

return a.value

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门