Packing data for a win32 'C' style system call to Winamp. help please!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    Packing data for a win32 'C' style system call to Winamp. help please!

    I am trying to talk to Winamp2 from Perl on Win32 system.
    According to winamp docs I need to send a windows message with the
    following structure: (To add a file to the playlist)

    COPYDATASTRUCT cds;
    cds.dwData = IPC_PLAYFILE;
    cds.lpData = (void *) "file.mp3";
    cds.cbData = strlen((char *) cds.lpData)+1; // include space for
    null
    SendMessage(hwn d_winamp,WM_COP YDATA,(WPARAM)N ULL,(LPARAM)&cd s);

    Somewhere else I found the structure to be defined as:

    COPYDATASTRUCT cds;
    cds.dwData = IPC_PLAYFILE;
    cds.cbData = lstrlen(filenam e) + 1;
    cds.lpData = (void *) filename;

    which makes more sense, because it defines the length of the
    filename before giving the pointer to it. However, this is confusing
    because surely the order of the structure as it gets packed makes a
    difference.

    This is my test code, and it doesn't work:

    <code start>
    use Win32::GUI;

    my $IPC_PLAYFILE = 100;
    my $mp3file = 'demo.mp3';
    my $wparam = pack("I", NULL);

    my $dwData = pack("L", $IPC_PLAYFILE);
    my $cbData = 9; #Hard coded length + 1 for test
    my $lpData = pack("p", $mp3file);
    my $lpCopydatastru ct = pack("pLp", $dwData, $cbData, $lpData);

    print Win32::GUI::Sen dMessage($winam pHandle, WM_COPYDATA, $wparam,
    $lpCopydatastru ct);
    <code end>

    I know the winamp handle part is okay, other simple messages work,
    but this one requires the c-style structure to be packed and I can't
    get it to work. Anyone done stuff like this before, got an example
    of how a C structure should be packed. Help please?

    Thanks.
Working...