What is the easiest way to use a DLL file from within Python?
Specifically, how can this be done without writing any additional wr
This page has a very simple example of calling functions from a DLL file.
Paraphrasing the details here for completeness:
It's very easy to call a DLL function in Python. I have a self-made DLL file with two functions:
addandsubwhich take two arguments.
add(a, b)returns addition of two numbers
sub(a, b)returns substraction of two numbersThe name of the DLL file will be "demo.dll"
Program:
from ctypes import*
# give location of dll
mydll = cdll.LoadLibrary("C:\\demo.dll")
result1= mydll.add(10,1)
result2= mydll.sub(10,1)
print "Addition value:"+result1
print "Substraction:"+result2Output:
Addition value:11
Substraction:9