Play wav sound from a resource file

Posted in Resource

The problem is not so difficult. You should include {$R MySoundRes.RES} line to the implementation section. And for playing wav sound you must use the PlaySound procedure. There is a 'SOUND' section which contents a musical file in the resource file.

{$R MySoundRes.RES}
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PlaySound('SOUND', 0, SND_RESOURCE);
end;