【发布时间】:2012-08-10 00:00:06
【问题描述】:
我在 python 中使用 DLL 函数时遇到问题。 我通过“dumpbin”查看了函数的名称。
例如
_xGraphics3D@20
我尝试这样调用函数:
from ctypes import *
xorsLib = cdll.LoadLibrary("Xors3D.dll")
width = c_int(800)
height = c_int(600)
depth = c_int(32)
mode = c_int(0)
vsync = c_int(0)
xGraphics3D = getattr(xorsLib,"_xGraphics3D@20")
xGraphics3D(width, height, depth, mode, vsync)
但它会导致错误:
Traceback (most recent call last):
File "D:/Coding/Python/pyASG/main", line 11, in <module>
xGraphics3D(width, height, depth, mode, vsync)
ValueError: Procedure called with not enough arguments (20 bytes missing) or wrong calling convention
我做错了什么?
附言我不知道python,但我学会了。我阅读了 ctype-manual 并试图找到答案...
p.p.s 对不起我糟糕的英语。
【问题讨论】:
-
在我的脑海中,您是否有机会使用 C++ 编译器?如果是这样,您可能需要声明您的函数
extern "C"以防止 C++ 的正常名称修改。参见例如this 文章。 -
这不是我的图书馆,我无权访问源代码。