我正在尝试访问位于64位处理器PC中“c:/Program Files(x86)”文件夹中的dll。
如果我使用os.path.exists检查dll是否存在,我会收到一个错误的答案:
>>> print os.path.exists('c:/Program Files (x86)/Some Folder/SomeDll.dll')
True
但是,当我尝试使用ctypes加载dll时,出现以下错误:
>>> from ctypes import WinDLL
>>> some_dll = WinDLL('c:/Program Files (x86)/Some Folder/SomeDLL.dll')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
在32位PC中,dll位于“c:/ProgramFiles”文件夹中,我可以毫无问题地打开它。我认为问题可能是文件夹名称中存在括号。由于返回的异常是WindowsError,因此它似乎是负责加载库的操作系统函数中的一个缺陷。
因此,问题是:如何加载位于“c:/ProgramFiles(x86)”文件夹中的dll?我无法将dll复制到其他目标,它
位于原始路径中。。。
非常感谢。