Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 10th April 2002, 09:33   #1
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
More FileName Crud.

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.

-Rz
Rz_Ten1 is offline   Reply With Quote
Old 10th April 2002, 18:01   #2
peter
ist death
 
peter's Avatar
 
Join Date: May 2000
Posts: 3,704
are you doing that in a plugin or in an external exe ?
peter is offline   Reply With Quote
Old 11th April 2002, 08:41   #3
Aus
French Canadian
(Alumni)
 
Aus's Avatar
 
Join Date: Dec 2001
Location: A shiny Igloo.
Posts: 333
Send a message via AIM to Aus
I think this is what you want.

code:

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];
}


Aus -- NoisePort.Org, chronicles of the french canadian alien (Temporarly down during the move).
Aus is offline   Reply With Quote
Old 11th April 2002, 17:33   #4
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
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.
Rz_Ten1 is offline   Reply With Quote
Old 11th April 2002, 18:12   #5
Aus
French Canadian
(Alumni)
 
Aus's Avatar
 
Join Date: Dec 2001
Location: A shiny Igloo.
Posts: 333
Send a message via AIM to Aus
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.

code:

#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);


Aus -- NoisePort.Org, chronicles of the french canadian alien (Temporarly down during the move).
Aus is offline   Reply With Quote
Old 11th April 2002, 20:26   #6
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
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.

Last edited by Rz_Ten1; 11th April 2002 at 21:23.
Rz_Ten1 is offline   Reply With Quote
Old 11th April 2002, 21:04   #7
peter
ist death
 
peter's Avatar
 
Join Date: May 2000
Posts: 3,704
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.
peter is offline   Reply With Quote
Old 11th April 2002, 21:22   #8
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
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.
Rz_Ten1 is offline   Reply With Quote
Old 11th April 2002, 21:47   #9
Aus
French Canadian
(Alumni)
 
Aus's Avatar
 
Join Date: Dec 2001
Location: A shiny Igloo.
Posts: 333
Send a message via AIM to Aus
Use FindWindow() and GetWindowText() then.

Aus -- NoisePort.Org, chronicles of the french canadian alien (Temporarly down during the move).
Aus is offline   Reply With Quote
Old 12th April 2002, 16:55   #10
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
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.
Rz_Ten1 is offline   Reply With Quote
Old 12th April 2002, 21:24   #11
peter
ist death
 
peter's Avatar
 
Join Date: May 2000
Posts: 3,704
i think there is some message that saves current playlist to winamp.m3u; you could use it, then read winamp.m3u
peter is offline   Reply With Quote
Old 15th April 2002, 17:22   #12
Rz_Ten1
Junior Member
 
Join Date: Apr 2002
Posts: 27
Yeah, I've seen that... I was just hoping there was a faster way. Thanks for the help everyone.
Rz_Ten1 is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump