View Single Post
Old 14th February 2010, 16:34   #1
corey.hannum
Junior Member
 
Join Date: Feb 2010
Posts: 2
SendMessage Enque Song in Playlist

Hello,

I'm trying to write a program in C# to do some basic Winamp functions (a functional SDK port instead of that which seems to be availalble for .net at SourceForge).

The really basic functions work (play, pause, stop, etc.) but I'm having some trouble with Enqueuing a song / sending a string.

The command arrives in Winamp, and winamp adds something to the playlist - unfortunatly not the string i wanted. It adds a bunch of garbage, and the garbage is always the same no matter what string i send (So I dont think it has to do with encoding)...

Following code:

[DllImport("user32.dll")]
public static extern int SendMessageA(int hwnd, int wMsg, int wParam, COPYDATASTRUCT lParam);

public struct COPYDATASTRUCT
{
public long dwData;
public long cbData;
public long lpData;
}

IntPtr temp;
COPYDATASTRUCT cds = new COPYDATASTRUCT();

cds.dwData = (long)IPC_PLAYFILE;
cds.lpData = (long)Marshal.StringToHGlobalUni(strURL);
cds.cbData = (long)strURL.Length + 1;

temp = Marshal.AllocHGlobal(Marshal.SizeOf(cds));
Marshal.StructureToPtr(cds, temp, false);

SendMessage(hwnd, WM_COPY_DATA, 0, (uint)temp);

Any suggestions?

Thanks in advance,

Corey
corey.hannum is offline   Reply With Quote