[Tutor] reg: How to import dll in python
Albert-Jan Roskam
fomcl at yahoo.com
Wed Mar 5 21:41:49 CET 2014
>________________________________
> From: Shweta Kaushik <k-shweta at hcl.com>
>To: "tutor at python.org" <tutor at python.org>
>Sent: Wednesday, March 5, 2014 1:49 PM
>Subject: [Tutor] reg: How to import dll in python
>import ctypes
>From ctypes import *
>testDll = cdll.LoadLibrary("D:\Python Test Codes\DLL_Test\Addition.dll")
>test1 = ctypes.WINFUNCTYPE(None)
>test2 = test1 (("add", testDll))
>
>Error Displayed
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>AttributeError: function 'add' not found
perhaps:
from ctypes import *
cppAdd = cdll.LoadLibrary(r"D:\Python Test Codes\DLL_Test\Addition.dll") # also note the r'
add = cppAdd.add
add.argtypes = [c_double, c_double]
add(1.0, 2.0)
More information about the Tutor
mailing list