在Vista上使用ctypes加载dll时访问被拒绝

1 投票
1 回答
1342 浏览
提问于 2025-04-15 14:53

我在使用ctypes的时候遇到了一些问题。我想在Vista系统上运行以下项目。

http://sourceforge.net/projects/fractalfrost/

我之前在Vista上用过这个项目,没遇到过任何问题。我查看了svn,没有发现有什么变化会导致这个问题,我觉得可能是这个机器本身的原因。实际上,我根本无法用ctypes加载dll文件。

Bobby@Teresa-PC ~/fr0st-exe/fr0st/pyflam3/win32_dlls
$ ls
Flam4CUDA_LIB.dll cudart.dll glew32.dll libflam3.dll pthreadVC2.dll

Bobby@Teresa-PC ~/fr0st-exe/fr0st/pyflam3/win32_dlls
$ python
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> flam3_dll = CDLL('libflam3.dll')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>> flam3_dll = CDLL('.\\libflam3.dll')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>> import os
>>> flam3_dll = CDLL(os.path.abspath('libflam3.dll'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>>

有没有什么想法可以解决这个问题,或者有没有什么方法可以绕过这个问题呢?

1 个回答

2

我知道这听起来有点傻,但因为你没有特别提到这一点:

你有没有检查一下你想要访问的文件的权限?也许你没有读取或执行这个文件的权限。

撰写回答