Posted: Sat Jun 21, 2003 10:11 pm Post subject: Playing sounds #2
--------------------------------------------------------------------------------
#include<iostream>
using namespacestd;
char DllDir[256]="";
string getDllDirFile(const char* basename)
{
if(strstr(basename,"..")){ return ":*?\\/<>\""; }
string ret = DllDir;
return (ret+basename);
}
void PlaySnd(char *Sound)
{
sndPlaySound(getDllDirFile(Sound).c_str(),SND_ASYNC);
}
in DLLMAIN
GetModuleFileName(hinstDll,DllDir,255);
char* pos = DllDir+strlen(DllDir);
while(pos>=DllDir && *pos!='\\') --pos;
pos[1]=0;
now to play a sound, PlaySnd("menu_activated.wav");
this code will look for the file menu_activate in the same directory as the dll.