"The Collector" <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list