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

Discussion in 'Perl' started by Andy, Sep 24, 2003.

  1. Andy

    Andy Guest

    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(hwnd_winamp,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);

    Somewhere else I found the structure to be defined as:

    COPYDATASTRUCT cds;
    cds.dwData = IPC_PLAYFILE;
    cds.cbData = lstrlen(filename) + 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 $lpCopydatastruct = pack("pLp", $dwData, $cbData, $lpData);

    print Win32::GUI::SendMessage($winampHandle, WM_COPYDATA, $wparam,
    $lpCopydatastruct);
    <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.
    Andy, Sep 24, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavin

    Embedding Winamp

    gavin, May 6, 2005, in forum: HTML
    Replies:
    5
    Views:
    6,346
    Spartanicus
    May 6, 2005
  2. Brent W. Hughes

    Possibly OT: Controlling winamp with Python

    Brent W. Hughes, Feb 4, 2005, in forum: Python
    Replies:
    7
    Views:
    508
  3. The Collector

    Controlling WinAMP (WM_COPYDATA problem)

    The Collector, Jun 30, 2005, in forum: Python
    Replies:
    3
    Views:
    1,292
    Christos TZOTZIOY Georgiou
    Jul 1, 2005
  4. Alf P. Steinbach

    Re: Pure virtual function call in Winamp?

    Alf P. Steinbach, Oct 23, 2009, in forum: C++
    Replies:
    12
    Views:
    1,021
    Vladimir Jovic
    Oct 28, 2009
  5. BadOmen
    Replies:
    1
    Views:
    188
    BadOmen
    Jan 8, 2004
Loading...

Share This Page