天天看点

Playing a wav file without TMediaPlayer

As you know ,to play a WAV sound, you can use a TMediaPlayer object. 

This article shows that how can playing a wav file without TMediaplayer. 

-------- 

declared in the mmsystem unit 

........ 

function PlayWav(const FileName: string): Boolean; 

begin 

Result := PlaySound(PChar(FileName), 0, SND_ASYNC); 

end; 

procedure StopWav; 

var 

buffer: array[0..2] of char; 

buffer[0] := #0; 

PlaySound(Buffer, 0, SND_PURGE); 

------------------------------- 

//Example: 

procedure TForm1.Button1Click(Sender: TObject); 

PlayWav('c:\windows\media\start.wav'); 

procedure TForm1.Button2Click(Sender: TObject); 

StopWav; 

    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2007/08/20/862484.html,如需转载请自行联系原作者

继续阅读