python如何调用dll库中的函数

602
2021/2/12 14:06:54
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python如何调用dll库中的函数

在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

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: python如何返回数组索引