// Declaration: sndplaysound (lpszsoundname: pchar; {sound file} uflags: uint {playback options}): bool; // optional value of the uflags parameter: snd_sync = 0; {synchronous playback, the program must wait until the playback is complete before executing} snd_async = 1; {asynchronous playback. After the function returns, the program starts playing. The program continues to be executed.} snd_nodefault = 2; {when the sound file is missing, the function automatically returns the default sound that is not played.} snd_memory = 4; {the sound in the player memory, for example, the sound in the resource file} snd_loop = 8; {loop playback, need to be combined with snd_async} snd_nostop = 16; {if the current playing sound is in progress, false is returned immediately}
// Example: Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; button3: tbutton; Procedure button1click (Sender: tobject); Procedure destroy (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses mmsystem; {sndplaysound declaration in this unit} const S = 'C: \ windows \ media \ Windows XP start .wav '; // play procedure tform1.button1click (Sender: tobject) synchronously ); begin sndplaysound (S, snd_sync); beep; {this sentence will be executed after playing} end; // procedure tform1.button2click (Sender: tobject); begin sndplaysound (S, snd_async); beep; {this sentence will be executed immediately} end; // play procedure tform1.button3click (Sender: tobject); begin sndplaysound (S, snd_loop or snd_async); end.
// Sndplaysound can also be used to play audio files in resources or memory. For example:
Http://www.cnblogs.com/del/archive/2008/02/15/1069523.html