![]() |
#1 |
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 |
![]() |
![]() |
![]() |
#2 |
Join Date: Sep 2003
Posts: 27,873
|
not knowing all of the C# syntax, i'd suggest making sure that it's a pointer to the string you're passing and not the address of the buffer holding it. and also that it is an ansi encoded string (or change IPC_PLAYFILE to the unicode IPC_PLAYFILEW variant if it's a unicode string you're working with). other than that not too much else i can think off with my limited knowledge with C# (though how you've declared SendMessageA(..) but used SendMessage(..) is a bit baffling).
-daz |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Feb 2010
Posts: 2
|
I copied the code together from a few places in my source - thats why you see SendMessageA - copied from the wrong place.
Manged Code seems to make working with pointers much more complicated than it used to be. I'm going to look into whether the pointer is pointing to the string or buffer.. Anyone eles have any other suggestions?? |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Aug 2020
Posts: 6
|
Seems like this code works
code: code: |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|