python - pygame 搞砸了 ctypes

标签 python winapi pygame ctypes

import mymodule, ctypes
#import pygame

foo = ctypes.cdll.MyDll.foo

print 'success'

如果我取消对 import pygame 的注释,则会失败并显示 WindowsError: [Errno 182] 操作系统无法加载 %1。堆栈框架在 ctypes python 代码中,试图加载 MyDll。 win32 错误代码 182 是 ERROR_INVALID_ORDINAL。如果 pygame 导入不存在,则脚本运行成功。

更新:如果我在调试器之外运行它,%1 会充满“libpng13.dll”,它在工作目录中并被 MyDll 引用,并且 pygame 肯定会加载某个版本的 libpng。我不知道如何解决这个问题。

最佳答案

这听起来像是 dll 冲突。似乎 import pygame 加载了一些与 MyDll 需要的 dll 不兼容的 dll。 您应该尝试使用 sysinternals ProcessExplorer 进行调试,它可以显示进程加载了哪些 dll;在这两种情况下寻找不同的 dll。

调试 dll 问题的另一个有用工具是 dependencywalker,来自 www.dependencywalker.com

关于python - pygame 搞砸了 ctypes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/686798/

相关文章:

winapi - Windows 10 上的 CreateSymbolicLink

c++ - 如何确定正在使用的图形卡 (Win32)

python - 如何在 Pygame 中将旋转图像设为 "Crop"

python - 找不到pygame

python - 我需要什么才能在我的浏览器中成功运行一个执行 Python 脚本的网站?

python - 如何从查询结果中去除 "Decimal"

c++ - 如何使一个子窗口在同一窗体中覆盖另一个子窗口?

python - 如何从 NumPy 数组制作标签?

python - 压缩大量相似的字符串

python - 鼠标点击矩形的困境