Include .Wav Files into your .EXE File (Views: 107)
How to Include .Wav Files into your .EXE File
Create a resource script file (*.RC) with a simple text editor like Notepad and add the following line:
1 WAVE "MyWav.wav"
The '1' is simply the index of the resource. The 'WAVE' specifies that we are dealing with a WAVE FILE user-defined resource. The third and final entry is the name of the Wav file.
User Borland's Resource Compiler, BRCC32.EXE, to compile it into a .RES file. At the MS- DOS command line, type:
This will create a resource file called MyWav.RES.
Add a compiler directive to the source code of your program. It should immediately follow the form directive, as shown here:
Add the following code to your project:
procedure TForm1.Button1Click(Sender: TObject);
PlaySound(PChar(1), HInstance, snd_ASync or snd_Memory or snd_Resource);
You can add as many .Wav files as you want, just by adding another index number to your list, and call it using the PChar(index) in the PlaySound line.
Run your program and click on the button, and enjoy.
Hint: MMSystem must be in the uses clause!
<< Back to main page