'Playing native Windows sounds in Inno Setup

In there any way to play Windows native sounds using Inno Setup?

For example I'm showing a custom message box, and I need to play Windows warning/info/error sound before showing that message. Any way?



Solution 1:[1]

Use PlaySound WinAPI function:

const
  SND_ASYNC = $0001;
  SND_ALIAS = $00010000; 

function PlaySound(pszSound: string; hmod: THandle; fdwSound: DWORD): BOOL;
  external '[email protected] stdcall';

Use it like:

PlaySound('SystemQuestion', 0, SND_ALIAS or SND_ASYNC);

For list of standard sound aliases, see:
https://docs.microsoft.com/en-us/windows/win32/multimedia/using-playsound-to-play-system-sounds

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1