Mega Code Archive

 
Categories / Delphi / Examples
 

Use a wave file as a resource in your exe

This is an unexpected easy procedure! You don't even need Borland's Resource Workshop for this task. Create a text file as shown in the table below; it should contain a link to the WAV file you want to include. Name this file e.g. "MySound.RC". If you want to include more than one WAV file, just add more lines with different identifiers in the first column. HELLO WAVE "c:/winnt40/media/chimes.wav" Then use the commandline resource compiler BRCC32.EXE like this: BRCC32 MySound.RC A resource file MySound.Res will be generated. Add this to your project and use it like this: uses MMSystem; {$R MySound.Res} procedure TForm1.PlaySndFromResClick(Sender: TObject); begin PlaySound('HELLO', hInstance, SND_RESOURCE or SND_SYNC); end;