procedure CloseSound;
var
hWinmm: Cardinal;
pwaveOutWrite: Pointer;
lp: Cardinal;
begin
hWinmm := LoadLibrary('Winmm.dll');
if hWinmm > 0 then
pwaveOutWrite := GetProcAddress(hWinmm, 'waveOutOpen');
if pwaveOutWrite <> nil then begin
VirtualProtect(pwaveOutWrite, 3, PAGE_EXECUTE_READWRITE, lp);
Move(#$C2#$18#$00, pwaveOutWrite^, 3);
end;
end;