win32 problem with WM_COPYDATA

Chris crjensen at gmail.com
Sat Nov 27 22:15:50 CET 2004


Yea... I changed it to Qserver while posting, but forgot to do both
spots.  But the array and struct thing worked, so its all going now. 
Thanks a bunch.  Any ideas about the Unregistering error?

"Neil Hodgson" <nhodgson at bigpond.net.au> wrote in message news:<OLUpd.49878$K7.14436 at news-server.bigpond.net.au>...
> Chris:
> 
> >         wc.lpszClassName = "QServer"
> > ...
> >             "QuoteServer App",
> > ...
> >     wnd = win32gui.FindWindow("QuoteServer", None)
> 
>    Using the same name helps.
> 
> > ...
> >     buff = struct.pack('11s', "XXXXX: YYYY")
> >     print win32gui.SendMessage(wnd, win32con.WM_COPYDATA, 0, buff)
> 
>    Copydata does not take an arbitrary pointer, it requires a correctly
> initialized COPYDATASTRUCT. From a Mark Hammond post:
> 
> import struct, array
> int_buffer = array.array("L", [0])
> char_buffer = array.array("c", "the string data")
> int_buffer_address = int_buffer.buffer_info()[0]
> char_buffer_address, char_buffer_size = char_buffer.buffer_info
> copy_struct = struct.pack("pLp",  # dword *, dword, char *
>                            int_buffer_address,
>                            char_buffer_size, char_buffer_address)
> # find target_hwnd somehow.
> win32gui.SendMessage(w, WM_COPYDATA, target_hwnd, copy_struct)
> 
>    Neil



More information about the Python-list mailing list