Thanks to everyone at CodeProject! It appears that the original post may not be clear. Therefore, consider the following code snippet which includes much more information about the problem and the (failed) attemtps to resolve it. Again, for reasons this beginner has yet to understand, PlaySound works fine with a filename constructed from a CString and a random number (/path/filename1.wav), but fails when concatenated CStrings are used to create a resouce identifier (IDR_WAVE_1). Please consider the code and coments below.
//Create random resource ID (similar approach used to create random wave file names)
int m\_nRandomSound;
m\_nRandomSound = getrandom( 500, 509 ); //Place the random number into the variable n\_nRandomRecord
CString m\_sStrRandomSound;
m\_sStrRandomSound = "";
CString m\_sStrRandomResourcePrefix; //Create the resource prefix
m\_sStrRandomResourcePrefix = "IDR\_WAVE\_";
m\_sStrRandomSound.Format("%d", m\_nRandomSound); //Convert the random integer to a CString
//Concatentate the strings into the resource identifier
CString m_sStrRandomResourcePrefixWav;
m_sStrRandomResourcePrefixWav = m_sStrRandomResourcePrefix + m_sStrRandomSound;
//Set the resource identifier directly
CString m_sStrRandomResourcePrefixWav2;
m_sStrRandomResourcePrefixWav2="IDR_WAVE_503";
//
//
//Demonstrate function similar method that plays sounds using concatenated CString of path/filename
PlaySound(m_sStrRandomSoundPathWav, GetModuleHandle(NULL), SND_FILENAME|SND_SYNC );
//PLAYS from concatenated CString
//(e.g. \path\filename?.wav - where ? is an integer converted to a CString)
PlaySound(MAKEINTRESOURCE(IDR_WAVE_503), GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
//PLAYS IDR_WAVE_503
//which is directly entered an not subtituted in any way
//
//
//ATTEMPTS TO EMPLOY CONCATENATED STRING TO PLAY RANDOM WAVE FILE
//PlaySound(MAKEINTRESOURCE(m_sStrRandomResourcePrefixWav), GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
//error C2440: 'type cast' : cannot convert from 'class CString' to 'unsigned short'
//included for completeness
//PlaySound(IDR_WAVE_503, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
//error C2664: 'PlaySoundA' : cannot convert parameter 1 from 'const int' to 'const char *'
//included for completeness
PlaySound(m_sStrRandomResourcePrefixWav2, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
//Compiles b