相关疑难解决方法(0)

Python | 使用ctypes访问dll

我正在尝试访问Firefox Web浏览器附带的dll(nss3.dll)中的某些功能.为了处理这个任务,我在Python中使用了ctypes.问题是它在将dll加载到内存时的初始点失败.

这是我必须这样做的代码片段.

>>> from ctypes import *
>>> windll.LoadLibrary("E:\\nss3.dll")
Run Code Online (Sandbox Code Playgroud)

我得到的例外是

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    windll.LoadLibrary("E:\\nss3.dll")
  File "C:\Python26\lib\ctypes\__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  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
Run Code Online (Sandbox Code Playgroud)

我也尝试从Firefox安装路径加载它,假设可能存在依赖关系.

>>> windll.LoadLibrary("F:\\Softwares\\Mozilla Firefox\\nss3.dll")
Run Code Online (Sandbox Code Playgroud)

但是我得到了与上面提到的相同的例外.

谢谢.

python windows dll firefox ctypes

16
推荐指数
3
解决办法
3万
查看次数

标签 统计

ctypes ×1

dll ×1

firefox ×1

python ×1

windows ×1