小编zou*_*umi的帖子

ctypes包装"MessageBoxA"示例在python33中不起作用

这个例子在python 3.3.2 doc中:

http://docs.python.org/3/library/ctypes.html?highlight=ctypes#ctypes

但是:当我在翻译中尝试它时,我收到一个错误.

我使用windows7 32 python 3.3.2.

请帮忙.

from ctypes import c_int, WINFUNCTYPE, windll
from ctypes.wintypes import HWND, LPCSTR, UINT
prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)
MessageBox()
MessageBox(text="Spam, spam, spam")
MessageBox(flags=2, text="foo bar")

error message:
Traceback (most recent call last):
File "<string>", line 250, in run_nodebug
File "<g1>", line 7, in <module>
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong …
Run Code Online (Sandbox Code Playgroud)

python ctypes

4
推荐指数
1
解决办法
1063
查看次数

标签 统计

ctypes ×1

python ×1