Python导入dll

paj*_*ajm 18 python dll ctypes

如何将winDLL导入python并能够使用其所有功能?它只需要双打和字符串.

Dav*_*nan 19

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.

For example:

>>> from ctypes import *
>>> windll.kernel32.GetModuleHandleW(0)
486539264
Run Code Online (Sandbox Code Playgroud)

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))
Run Code Online (Sandbox Code Playgroud)