Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Long
'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep
Private Declare PtrSafe Function MessageBeep& Lib "user32.dll" (ByVal dwFlags As Long)
Sub a()
PlaySound "C:\Windows\Media\Windows Critical Stop.wav", ByVal 0&, &H20001
End Sub
Sub b()
MessageBeep &HFFFFFFFF
'MessageBeep vbOK
'MessageBeep vbError
'MessageBeep vbCritical
'MessageBeep vbExclamation
'MessageBeep vbInformation
End Sub
Sub d()
Beep
End Sub
Declare PtrSafe Function ApiBeep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Sub jouerbeepperso() 'joue 4 notes differentes d'une durée de 50 millisecondes
ApiBeep 1000, 50: ApiBeep 800, 50: ApiBeep 500, 50: ApiBeep 200, 50
End Sub
Sub joueSonWindowSapiVoice()
Const wavFile = "C:\Windows\Media\Windows Exclamation.wav"
Dim oVoice: Set oVoice = CreateObject("SAPI.SpVoice")
Dim oSpFileStream: Set oSpFileStream = CreateObject("SAPI.SpFileStream")
oSpFileStream.Open wavFile
oVoice.SpeakStream oSpFileStream
oSpFileStream.Close
End Sub
Sub ee()
ApiBeep 261.625, 500
ApiBeep 261.625, 500
ApiBeep 261.625, 500
ApiBeep 293.664, 500
ApiBeep 329.627, 1000
ApiBeep 293.664, 1000
ApiBeep 261.625, 500
ApiBeep 329.627, 500
ApiBeep 293.664, 500
ApiBeep 293.664, 500
ApiBeep 261.625, 500
End Sub
MERCI BEAUCOUP je vais essayer tout caLe Beep API est pratique:
VB:Sub ee() ApiBeep 261.625, 500 ApiBeep 261.625, 500 ApiBeep 261.625, 500 ApiBeep 293.664, 500 ApiBeep 329.627, 1000 ApiBeep 293.664, 1000 ApiBeep 261.625, 500 ApiBeep 329.627, 500 ApiBeep 293.664, 500 ApiBeep 293.664, 500 ApiBeep 261.625, 500 End Sub
bonjour,
3 méthodes:
VB:Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Long 'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep Private Declare PtrSafe Function MessageBeep& Lib "user32.dll" (ByVal dwFlags As Long) Sub a() PlaySound "C:\Windows\Media\Windows Critical Stop.wav", ByVal 0&, &H20001 End Sub Sub b() MessageBeep &HFFFFFFFF 'MessageBeep vbOK 'MessageBeep vbError 'MessageBeep vbCritical 'MessageBeep vbExclamation 'MessageBeep vbInformation End Sub Sub d() Beep End Sub