Python导入dll [英] Python import dll

查看:155
本文介绍了Python导入dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将winDLL导入python并能够使用其所有功能?

How would I import a winDLL into python and be able to use all of its functions? It only needs doubles and strings.

推荐答案

您标记了 ctypes ,所以听起来你已经知道答案。

You've tagged the question ctypes and so it sounds like you already know the answer.

类型教程非常出色。一旦您阅读并理解您将能够轻松完成。

The ctypes tutorial is excellent. Once you've read and understood that you'll be able to do it easily.

例如:

>>> from ctypes import *
>>> windll.kernel32.GetModuleHandleW(0)
486539264

还有一个我自己的代码的例子:

And an example from my own code:

lib = ctypes.WinDLL('mylibrary.dll')
#lib = ctypes.WinDLL('full/path/to/mylibrary.dll')
func = lib['myFunc']#my func is double myFunc(double);
func.restype = ctypes.c_double
value = func(ctypes.c_double(42.0))

这篇关于Python导入dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆