#python导入.dll文件时,文件夹中包含多个依赖,怎么导入?
import ctypes
# 定义 DLL 文件路径和名称
import os
dll_path = './WinSocketServer.dll'
# 加载 DLL 文件
# mydll = ctypes.CDLL(dll_path)
import ctypes
os.add_dll_directory(os.path.dirname(os.path.abspath(__file__)))
mydll = ctypes.CDLL('WinSocketServer.dll',winmode=0)
# lib = ctypes.cdll.LoadLibrary('example.dll')
lib = ctypes.CDLL('example.dll')
print(lib.triple(3))
if mydll is not None:
print("DLL 文件加载成功!")
else:
print("DLL 文件加载失败!")
问题报错如下:
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'WinSocketServer.dll' (or one of its dependencies). Try using the full path with constructor syntax.
【相关推荐】