Where does python look for a dll opened by ctypes.cdll. on windows?

前端 未结 2 958
借酒劲吻你
借酒劲吻你 2021-01-05 02:17

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

2条回答
  •  广开言路
    2021-01-05 02:58

    Loading a custom DLL in a custom folder using the Windows API takes a few steps:

    1. Confirm where they are using file system calls - something like a whole heap of lines looking something like: if path.exists(cwd() + "bin" + "mydll.dll"): return cwd() + "bin". Or if you're feeling brave just set the path.
    2. Use ctypes to load the Kernel32.dll - it knows where that one is natively.
    3. Load SetDllDirectory from Kernel32.dll. Call it with the path where you know where your dlls are.
    4. Now LoadLibrary will search for Dlls in that folder, so you can use ctypes to load your dll and call your functions.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题