How to find a dll with Python

Viewed 3469

I have some code that is supposed to load a .dll. I'm using Python version 3.0.17114.1 with Visual Studio 2017 Preview. Here is a code snip:

from ctypes.util import find_library
theDll = find_library('DsiLibrary_dll')

theDll comes out "None" which means it can't be found.

Note that a google search said that I should not add .dll:

#from "https://docs.python.org/3/library/ctypes.html"
#name is the library name without any prefix like lib, suffix like .so, .dylib

I checked SO and in one example a guy did use .dll. So I have tried adding .dll but no help. Then I also tried using cdll.find_library but that doesn't work either.

So I added this to be sure the .dll is there:

print ("Current directory:")
os.system("cd")
os.system("dir /s/b DsiLibrary_dll.dll")

The output is this:

Current directory:
L:\DSI (His) Try 5\Windows Apps\PythonSample
L:\DSI (His) Try 5\Windows Apps\PythonSample\DsiLibrary_dll.dll

Which shows that the dll is there.

I'm new at Python but I'm hoping someone can help here.

0 Answers
Related