gpt4 book ai didi

Python ctypes 和没有足够的参数(缺少 4 个字节)

转载 作者:可可西里 更新时间:2023-11-01 14:20:27 28 4
gpt4 key购买 nike

我要调用的函数是:

void FormatError (HRESULT hrError,PCHAR pszText);

使用 windll 从自定义 dll。

c_p = c_char_p()
windll.thedll.FormatError(errcode, c_p)

结果:

ValueError: Procedure probably called with not enough arguments (4 bytes missing)

改为使用 cdll 将字节丢失计数器增加到 12。上面的错误代码是从同一 dll 的另一个函数返回的错误代码。如何正确接听电话?

最佳答案

至少,如果您正确设置了 argtypes,您将获得更多描述性错误。和 restype .

尝试这样做:

windll.thedll.FormatError.argtypes = [ctypes.HRESULT, ctypes.c_char_p]
windll.thedll.FormatError.restype = None

您也很有可能使用了错误的调用约定 -- 查看 the Calling Functions sectionthe Loading Libraries section有关如何使用不同调用约定的详细信息。

关于Python ctypes 和没有足够的参数(缺少 4 个字节),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1458813/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com