cpython: 3031e4a95131 (original) (raw)
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1672,32 +1672,30 @@ different ways, depending on the type an
The optional third item is the default value for this parameter.
-This example demonstrates how to wrap the Windows MessageBoxA
function so
+This example demonstrates how to wrap the Windows MessageBoxW
function so
that it supports default parameters and named arguments. The C declaration from
the windows header file is this::
WINUSERAPI int WINAPI
LPCSTR lpText,[](#l1.16)
LPCSTR lpCaption,[](#l1.17)
LPCWSTR lpText,[](#l1.18)
LPCWSTR lpCaption,[](#l1.19) UINT uType);[](#l1.20)
Here is the wrapping with :mod:ctypes
::
>>> from ctypes import c_int, WINFUNCTYPE, windll
paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)
-The MessageBox foreign function can now be called in these ways::
prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
MessageBox = prototype(("MessageBoxW", windll.user32), paramflags) +
+The MessageBox
foreign function can now be called in these ways::
>>> MessageBox()
>>> MessageBox(text="Spam, spam, spam")
>>> MessageBox(flags=2, text="foo bar")
A second example demonstrates output parameters. The win32 GetWindowRect
function retrieves the dimensions of a specified window by copying them into