' No Device carte Son (pour savoir si elle existe)
Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
' Version mémoire
Private Declare Function sndPlaySoundmem Lib "winmm.dll" Alias "PlaySoundA" ( _
ByVal lpszName As Long, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Private Const SND_SYNC As Long = &H0 ' Attend que le son soit joué pour revenir
Private Const SND_ASYNC As Long = &H1 ' Démarre le son et reviens
Private Const SND_NODEFAULT As Long = &H2 ' Si problème, n'émettra pas de bip
Private Const SND_MEMORY As Long = &H4 ' Le son est en mémoire
Private Const SND_LOOP As Long = &H8 ' Joue en boucle (arrêt = sndPlaySound(Null, SND_SYNC)
Private Const SND_NOSTOP As Long = &H10 ' N'interrompt pas le son en cours
Private Const SND_NOWAIT As Long = &H2000 ' N'attend pas après le driver si occupé
' Important : La variable doit rester vivante même après la sortie de la Sub "JoueSonMémoire"
Private aSon() As Byte
Public Sub JoueSonMémoire()
' Joue un son pour attirer l'attention (depuis ressource)
On Error Resume Next
' Test s'il existe une carte son
If waveOutGetNumDevs <> 0 Then
' Définit le fichier son
aSon = LoadResData(4013, "SON.MESSAGE")
' Joue le son
Call sndPlaySoundmem(VarPtr(aSon(0)), _
0, _
SND_NOWAIT Or SND_NODEFAULT Or SND_MEMORY Or SND_ASYNC)
End If
End Sub