I am trying to access a dll located in the "c:/Program Files (x86)" folder in a 64-bits processor PC.
If I use os.path.exists to check if the dll exists, I receive an afirmative answer:
>>> print os.path.exists('c:/Program Files (x86)/Some Folder/SomeDll.dll')
True
But when I try to load the dll using ctypes, I get the following error:
>>> 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
In 32-bit PCs the dll is located in the "c:/Program Files" folder and I can open it without problems. I think that perhaps the problem is the presence of parenthesis in the folder name. As the returned exception was a WindowsError, it seems that it is a flaw in the operating system function responsible of loading libraries.
So, the question is: how do I load a dll located in the "c:/Program Files (x86)" folder? I can't copy the dll to another destination, it must be located in the original path...
Thank you!