Python ctypes: loading DLL from from a relative path

前端 未结 4 1663
挽巷
挽巷 2020-12-15 04:40

I have a Python module, wrapper.py, that wraps a C DLL. The DLL lies in the same folder as the module. Therefore, I use the following code to load it:



        
4条回答
  •  被撕碎了的回忆
    2020-12-15 05:41

    Another version:

    dll_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'MyCDLL.dll')
    myDll = ctypes.CDLL(dll_file)
    

提交回复
热议问题