I\'m afriad I couldn\'t find a simple answer for this on the internet, so maybe there will be one in the future because of this question!
I\'m using pywiiuse, a pyth
The Windows DLL search order is documented on MSDN. It's not Python-specific, and there is no way to change the search order from a command-line option. (But see the linked article for other ways to influence the search order.)
The source to ctypes/__init__.py does:
from _ctypes import LoadLibrary as _dlopen
I wasn't able to find the definition of LoadLibrary
in _ctypes.c, but presumably it is a wrapper for the Windows LoadLibraryEx function that behaves similarly to the POSIX dlopen function, because that is how it is used.
If you can modify the Python source to use the ctypes.CDLL
constructor instead, it should work:
folder = os.path.dirname(os.path.abspath(__file__))
dll_path = os.path.join(folder, "wiiuse.dll")
dll = ctypes.CDLL(dll_path)
If that isn't viable, you may be able to monkey-patch ctypes to handle this specific case, but that seems a bit dangerous. Perhaps just copying the DLL to be in the same folder with the Python DLL would be the easiest alternative.
Loading a custom DLL in a custom folder using the Windows API takes a few steps:
if path.exists(cwd() + "bin" + "mydll.dll"): return cwd() + "bin"
. Or if you're feeling brave just set the path.