Microsoft DirectX 8.1 (C++) |
The DirectSound API does not include methods for reading a wave from a resource. However, the Dsutil.cpp file used by many of the SDK sample applications implements a CWaveFile class that can read waves stored as resources as well as wave files.
To store wave sounds in an executable, import your wave files as resources and give them string names. Note that CWaveFile expects these resources to be of type "WAVE" or "WAV", and expects to find them in the executable module rather than a DLL.
The following code opens a resource identified as "mywave":
CWaveFile waveFile;
if (FAILED(waveFile.Open("mywave", NULL, WAVEFILE_READ)))
{
waveFile.Close();
}
Once the resource has been opened, it can be read from just as if it were a file. For more information on how to do this by using the CWaveFile class, see Reading Wave Files.