Re: Controlling WinAMP (WM_COPYDATA problem)
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Controlling WinAMP (WM_COPYDATA problem)

From: Thomas Heller <theller@python.net>
Date: Thu Jun 30 2005 - 22:13:35 CEST

"The Collector" <thecollector.2k@gmail.com> writes:

> Hi,
>
> I've been looking for almost two full days now to get full control of
> WinAMP using python. Simple play/stop functions are no problem. It's
> the WM_COPYDATA that's used by IPC_PLAYFILE (=add a file to the
> playlist) that's giving me troubles big time!
>
> My latest test code:
> ---------------------------------------
[reformatted the packData function]

def packData( dwData, lpData ):
    # calculate the pointer address for the lpData
    lpData_ad = array.array('c', lpData).buffer_info()[0]
    # calculate the length of the lpData (=cbData)
    cbData = array.array('c', lpData).buffer_info()[1]
    # pack dwData, cbData and lpData into a copyDataStruct
    cds = struct.pack("IIP", dwData, cbData, lpData_ad)
    # find the pointer address of the copyDataStruct
    cds_ad = array.array('c', cds).buffer_info()[0]
    # return the copyDataStruct pointer-address
    return cds_ad

>From a quick inspection of the packData function:

You need to keep the array instances alive! You only retrieve the
addresses, and the array instances itself are deleted immediately, so
the addresses are no longer valid.

(Hint: ctypes might also be a solution for you - it allows flexible
creation of C compatible data structures)

Thomas
Received on Thu Sep 29 16:40:29 2005