title: How to stop music started via SndPlaySound
body: <p>At this <a href="http://delphi.about.com/od/objectpascalide/a/embed_resources_2.htm" rel="nofollow">Website</a> I  found how to add music into a .res file and then use it in your delphi .exe. Here is the code for starting the WAVE song.</p>
  
  <pre><code>procedure TForm2.FormActivate(Sender: TObject);
  var
     hFind, hRes: THandle;
     Song: PChar;
   begin
    hFind := FindResource(HInstance, 'SonicSong', 'WAVE') ;
    if hFind &lt;&gt; 0 then begin
      hRes:=LoadResource(HInstance, hFind) ;
      if hRes &lt;&gt; 0 then begin
        Song:=LockResource(hRes) ;
        if Assigned(Song) then SndPlaySound(Song, snd_ASync or snd_Memory) ;
        UnlockResource(hRes) ;
      end;
      FreeResource(hFind) ;
    end;
  end;
  </code></pre>
  
  <p>So what I would like to know is how do I stop the music when I want to without closing the application?</p>