469,898 Members | 1,734 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

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(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.
Jul 19 '05 #1
0 1821

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by TheCoder | last post: by
18 posts views Thread by Edward Diener | last post: by
2 posts views Thread by Robert Smith jr. | last post: by
6 posts views Thread by Tejpal Garhwal | last post: by
4 posts views Thread by Thomas Eichner | last post: by
reply views Thread by Shyam Barnwal | last post: by
1 post views Thread by Shyam Barnwal | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.