To include a WAV file in a resource, see this post.
Note that the Windows PlaySound API can Play a WAV file directly from a resource.
PlaySound(SoundNameInTheResource, HInstance, SND_RESOURCE);
Hint: many (most?) questions have already been asked and answered, so a forum search is often a good idea before posting.
Hi Trev,
Thanks for your reply.
The old thread you quoted does not indicate what unit to use. The error is in
S := TResourceStream.Create(HInstance, wavename, RT_RCDATA);
Note the sounds.rc file is in place and properly included
{$IFDEF WINDOWS}
{$r sounds.rc}// user defined resource file
{$ENDIF}
I then deleted Tmainform.MakeSoundFiles and used the playsound suggestion.
It now compiles OK, but no sound.
procedure TForm1.Button1Click(Sender: TObject);
begin
PlaySound('Foghorn1', HInstance, SND_RESOURCE);
end;
The object is not to detach any files, but have the sound file play from within the .exe.
This is why I am struggling with old threads. It appears to be a follow on from a previews thread where the appropriate unit was declared.