简体   繁体   English

功能名称无效的Python和C-dll

[英]Python and C-dll with invalid name of function

I have a problem with using DLL function in python. 我在python中使用DLL函数时遇到问题。 I looked the name of function by dint of "dumpbin". 我用“ dumpbin”的名字看了函数的名字。

For example 例如

_xGraphics3D@20 _xGraphics3D @ 20

I tried to call the function like this: 我试图这样调用该函数:

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)

but it's cause the error: 但这会导致错误:

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

what am i doing wrong? 我究竟做错了什么?

ps i haven't know python, but i learn it. 附言:我不了解python,但我学到了。 i read ctype-manual and tried to find answer... 我读了ctype-manual并试图找到答案...

pps sorry for my awful english. PPS对不起,我的英语不好。

Try use windll instead of cdll. 尝试使用windll而不是cdll。
xorsLib = windll.LoadLibrary("xors3d.dll") http://docs.python.org/release/3.1.5/library/ctypes.html xorsLib = windll.LoadLibrary("xors3d.dll") http://docs.python.org/release/3.1.5/library/ctypes.html
The reason is the same as martineau commented. 原因与martineau评论的相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM