Where python is looking for a DLL open by ctypes.cdll. <Name> on the windows?

I am African. I could not find a simple answer to this on the Internet, so maybe in the future there will be one of them because of this question.

I am using pywiiuse, the python shell for the C wiiuse library on windows. I got some simple C examples by simply including the DLL, header and library in the source directory.

However, I am wondering where to put the dll so that pywiiuse will find it. A look at the source shows that it loads as follows:

dll = ctypes.cdll.wiiuse

Running the examples gives an exception not found by the module when I have a dll in the same directory as in my test case.

Where is python looking for a dll?

+6
2

Windows DLL MSDN. Python, . ( . .)

ctypes/__init__.py :

from _ctypes import LoadLibrary as _dlopen

LoadLibrary _ctypes.c, Windows LoadLibraryEx, POSIX dlopen .

Python ctypes.CDLL , :

folder = os.path.dirname(os.path.abspath(__file__))
dll_path = os.path.join(folder, "wiiuse.dll")    
dll = ctypes.CDLL(dll_path)

, ctypes monkey-patch , . , DLL Python DLL .

+4

DLL Windows API :

  • , - - , : if path.exists(cwd() + "bin" + "mydll.dll"): return cwd() + "bin". , , .
  • ctypes Kernel32.dll - , .
  • SetDllDirectory Kernel32.dll. , , DLL.
  • LoadLibrary Dll , ctypes DLL .
+1

All Articles