I have a WinForms app. This app has a Preferences section where the user will be able to select which sounds are played when an alert is being displayed.
Is it possible to have a combobox where the user can select from the Windows stored sounds such as "critical stop", "critical beep" and so on. These are found in the "Control Panel" >> "Sounds and Alerts" section.
Is it also possible to have a play button to test the sounds out?
You do not require any API to play system sounds just write code like this:
The
SystemSounds
class contains the following predefined system sounds:All other sounds require you read the desired sound from the registry and play it with code like this:
Sure! All the sounds you're looking for are available through the
System.Media.SystemSounds
class, where they are exposed as public properties corresponding to the event types that trigger the sounds.Additionally, objects of the
SystemSound
class provide aPlay
method that you can call to play that sound asynchronously.So for example, to play the "Critical Stop" sound, you would simply write the following code:
Try this: