Notice we unlock the data, we do no free it. Thus when reading the file, always check if it is valid. A few comments about WAV files. WAV files evolved over many years starting with the simple format of a header followed by data. Later it changed into a general purpose file, involving chunks of data which can contain information besides sound information.
Many programs deal with a wave file as a header followed by data.
This greatly simplifies the programming necessary to deal with these files and will work when there is only sound data in the file. However, the correct way of dealing with sound files is to open them as multi-media files using the mmioXXXX routines. Playing out the Clipboard. A sound in the clipboard is nothing but a memory image of a WAV file. It is very simple to play out a WAV file memory image using playsound.