このWeb サイトで、音楽を .res ファイルに追加し、それを delphi .exe で使用する方法を見つけました。WAVE ソングを開始するためのコードは次のとおりです。
procedure TForm2.FormActivate(Sender: TObject);
var
hFind, hRes: THandle;
Song: PChar;
begin
hFind := FindResource(HInstance, 'SonicSong', 'WAVE') ;
if hFind <> 0 then begin
hRes:=LoadResource(HInstance, hFind) ;
if hRes <> 0 then begin
Song:=LockResource(hRes) ;
if Assigned(Song) then SndPlaySound(Song, snd_ASync or snd_Memory) ;
UnlockResource(hRes) ;
end;
FreeResource(hFind) ;
end;
end;
それで、私が知りたいのは、アプリケーションを閉じずに、必要なときに音楽を停止する方法です。