Playing tunes from the resource

Started by !artem!, 18 Jun '11 - 16:08

!artem!

I have to share some *. wav files
how to play a *. wav file located in the resource?

PS
I write with the aid of google translator, I'm sorry if there are errors

Ian @ un4seen

You can use the FindResource and LoadResource functions to "load" the resource, and then use LockResource and SizeofResource to get the address and size of it, which you can then use in a BASS_StreamCreateFile call. Something like this...

HRSRC rsrc=FindResource(NULL, resourcename, RT_RCDATA);
HGLOBAL global=LoadResource(NULL, rsrc);
HSTREAM stream=BASS_StreamCreateFile(TRUE, LockResource(global), 0, SizeofResource(NULL, rsrc), 0);
BASS_ChannelPlay(stream, FALSE);