how to replace Windows.Beep with modern beep sound that comes from speakers with adjustable volume?
Try this one
uses MMSystem;
procedure TForm1.Button1Click(Sender: TObject);
begin
sndPlaySound('C:\Windows\Media\sound.wav',
SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
sndPlaySound(nil, 0); // Stops the sound
end;
Funny you should ask. I was just reading about the history of the windows beep. The Americans with Disabilities act has forced the Beep API to not change for the last 20 something years.
For Windows 7, we resolved the issue completely – we moved all the functionality that used to be contained in Beep.Sys into the user mode system sounds agent – now when you call the Beep() API instead of manipulating the 8254 chip the call is re-routed into a user mode agent which actually plays the sounds.
So the short answer is: Get Windows 7. A longer answer would be: Don't use the beep api. Get a beep noise and play it like you'd play any other noise.
If you want to use the "standard" beeps used by Windows when a MessageBox is displayed, you can call Windows.MessageBeep(MessageID)
where MessageID maps to the same values as the icon ids for MessageBox (MB_OK, MB_ERROR etc).
One problem with this is that users can map any, or no sound to particular ids.
You can replace beep calls with executing ET BEEP which has editor for all sorts of alien sounds.