View Full Version : More FileName Crud.
Rz_Ten1
10th April 2002, 09:33
Hello. I've been following the FileName discussion messages, and am still at a bit of a loss. I can get everything alright up until the pointer, but when I try to do a copy I just get an access violation.
I'm currently using MSVC++ 6.
Here's the code:
int index = SendMessage(hwndWinamp, WM_USER, 0, 125); //returns the playlist position
long filename=SendMessage(hwndWinamp, WM_USER, index, 211);
CHAR file[255] ;
lstrcpy(file,filename);
If anyone can tell me how I've horribily screwed up I'd be grateful. :D
-Rz
peter
10th April 2002, 18:01
are you doing that in a plugin or in an external exe ?
Aus
11th April 2002, 08:41
I think this is what you want.
char *GetSongTitle(char * szBuffer)
{
int iPos = 0;
char *p;
iPos = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETLISTPOS);
p = (char *)SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM)iPos, IPC_GETPLAYLISTTITLE);
strcpy(szBuffer, p);
return &szBuffer[0];
}
Rz_Ten1
11th April 2002, 17:33
Well, that had a slighty different effect:
WINAMP caused an invalid page fault in
module WINAMP.EXE at 017f:0041de76.
and then I get the standard Access Violation from the program.
Any ideas?
--And it is an external file, yes.
Aus
11th April 2002, 18:12
you need to make the buffer you pass large enough to old the song, might i suggest something like... 512bytes or 1024.
Here's the same function as before but I modified it to match exactly what you need. Infact, it's not even a function anymore. :p
#include <frontend.h>
...
int iPos = 0;
char *p;
char szBuffer[1024] = {0};
iPos = SendMessage(hwndWinamp, WM_WA_IPC, 0, IPC_GETLISTPOS);
p = (char *)SendMessage(hwndWinamp, WM_WA_IPC, (WPARAM)iPos, IPC_GETPLAYLISTTITLE);
strcpy(szBuffer, p);
Rz_Ten1
11th April 2002, 20:26
Nope, still crashing with an access violation.
It actually looks like p itself is causing the crash, not the strcpy. If I try to dump p anywhere else, I get the same crash.
I also tried allocating memory for the pointer (p=new char[1024];) but it seems to have no effect.
peter
11th April 2002, 21:04
you can't get filenames, etc from an external exe (RTFM) because returned pointers aren't valid (and will never be) in your process space. if you really need them, write a plugin which gets filenames and comunicates with your program using WM_COPYDATA, DDE or something else.
Rz_Ten1
11th April 2002, 21:22
I see. Is there any way to do it outside of a plugin other then the list dump method? I would rather not have it be plugin based.
Aus
11th April 2002, 21:47
Use FindWindow() and GetWindowText() then.
Rz_Ten1
12th April 2002, 16:55
While that would and does work, I'm trying to get the filename, not the title. I'd like to do my own ID3 processing.
peter
12th April 2002, 21:24
i think there is some message that saves current playlist to winamp.m3u; you could use it, then read winamp.m3u
Rz_Ten1
15th April 2002, 17:22
Yeah, I've seen that... I was just hoping there was a faster way. Thanks for the help everyone. :)
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.