Using sndPlaySound to play a wave file!

This is how we do it…

[sourcecode language=’cpp’]// Include file
#include “mmsystem.h”

// Link to this library
#pragma comment( lib, “winmm.lib” )

int main( int argc, char **argv )
    // Will block till the whole file is played, use SND_ASYNC to play asynchronously
    sndPlaySound( “c://windows//media//ding.wav”, SND_SYNC );

    // Play for ever, should use SND_ASYNC
    sndPlaySound( “c://windows//media//ding.wav”, SND_ASYNC|SND_LOOP );

    // Sleep for 5 seconds
    Sleep( 5000 );

    // Enough is enough stop making that stupid noise
    sndPlaySound( NULL, SND_SYNC );

    return 0;
}// End main[/sourcecode]

One thought on “Using sndPlaySound to play a wave file!

Appreciate your comments...