"Universal Gateway"

Thomas Heller theller at python.net
Fri Nov 8 09:49:11 EST 2002


Paul Moore <gustav at morpheus.demon.co.uk> writes:

> Thomas Heller <theller at python.net> writes:
> 
> > Ok, it seems I cannot escape, now that ctypes also was mentioned in
> > the Daily Python-URL, so I will also announce it here, after some
> > cleanup.
> 
> Having looked at this, I'm very impressed. calldll did the job, but I
> was never completely happy with its interface. Your code is far nicer,
> and makes things very clean.
> 
> I was interested in the support for callbacks, and as there wasn't a
> sample script in the distribution, I had a go at writing one. Took me
> no more than a few minutes (most of which was looking up prototypes in
> MSDN!) and worked straight off. It was a very nice experience :-)
> 
> In case you're interested, here's the code (just lists the window
> titles of all the windows in the system).
> 
> ---- cut here ----
> 
> from ctypes import windll, CFunction, c_string
> user32 = windll.user32
> 
> class EnumWindowsProc(CFunction):
>     _types_ = "ii"
>     _stdcall_ = 1
> 
> def DisplayWindow(hwnd, lparam):
>     title = c_string('\000' * 256)
>     user32.GetWindowTextA(hwnd, title, 255)
>     print title.value
> 
> enumproc = EnumWindowsProc(DisplayWindow)
> 
> user32.EnumWindows(enumproc, 0)

Great! With your permission, I will add this to the example scripts.

So, it seems, the interface is intuitive, and the docs are good enough
at explaining the details.

Hm, looking at the HTML files, they are nearly as large as the .pyd
files.

Looking further: there is still a lot which isn't mentioned in the
docs, so I still have to catch up with writing.

Thomas



More information about the Python-list mailing list