Controlling WinAMP (WM_COPYDATA problem)

Thomas Heller theller at python.net
Thu Jun 30 16:13:35 EDT 2005


"The Collector" <thecollector.2k at 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



More information about the Python-list mailing list