[docs] [issue21903] ctypes documentation MessageBoxA example produces error

Eryk Sun report at bugs.python.org
Wed Sep 28 17:33:54 EDT 2016


Eryk Sun added the comment:

The GetWindowRect example seems fine, for the most part. The docs don't have to show it being called. If I were to call it, I'd use GetForegroundWindow to get a window handle. GetActiveWindow returns the active window attached to the current thread's message queue, but a console application probably doesn't own a window. (The console window is owned by conhost.exe.)

A more pressing matter is the GetModuleHandle examples, which need to either be fixed or replaced. GetModuleHandle returns a module's base address, and in a 64-bit process the result could be truncated when returned as the default C int type. GetModuleHandleW.restype has to be set to a pointer type. Setting it to a Python function, such as the ValidHandle example, has the same truncation problem. In general, a ValidHandle checker would have to be implemented as an errcheck function.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21903>
_______________________________________


More information about the docs mailing list