Archived

This topic is now archived and is closed to further replies.

TNTGames

Music from resources in Games

Recommended Posts

Hey! I want to load music from a resource and not from a file seperate from the .exe file. I know how to do this with the PlaySound() function but i want to use DSound to do it.... I can''t figure out how to use mmioOpen() to do this... Any tips? Advice? Thanks, TNTGames

Share this post


Link to post
Share on other sites
You can do it like this:


HRSRC hResource;
HGLOBAL hResGlobal;
unsigned long resSize;
void *pData = NULL;

hResource = FindResource(NULL, resName, "WAVE"); // (for wave files)

hResGlobal = LoadResource(NULL, hResource);
// get size of the resource

resSize = SizeofResource(NULL, hResource);
// get pointer to the resource

pData = LockResource(hResGlobal);

/*After this you can use pData to for example, memcpy it into a buffer, check that the data is an appropriate sound file and copy it into a DirectSoundbuffer*/

Share this post


Link to post
Share on other sites