delphi 播放wav声音
procedure TForm13.btn1Click(Sender: TObject);
begin
play_wav_bykeys('1',0);
end;
function TForm13.play_wav_bykeys(filename: string; xflag: Integer): boolean; // xflag=1 wait play; xflag=0;nowait
const
SND_DIR = '.\wav\';
var
s,f:String;
begin
sndPlaySound(nil, 0); //停止发音
s :=Format('%s%s.wav',[SND_DIR,filename]);//播放wav文件夹下filename声音文件
if FileExists(s) then
begin
if xflag = 0 then sndPlaySound(PChar(s), SND_ASYNC)
else sndPlaySound(PChar(s), SND_SYNC);
end;
end;