Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long Private Declare Function PlaySoundA Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Dim m() As Byte
Public Sub PlaySoundInMemory(ResName, Optional Wait As Boolean = False) Dim resErr As Long, Flags As Long
On Error Resume Next Err.Clear m = LoadResData(ResName, "WAVE") resErr = Err.Number If resErr = 0 Then Flags = SND_NODEFAULT Or SND_MEMORY Or SND_SYNC If Wait = False Then Flags = Flags Or SND_ASYNC sndPlaySound m(0), Flags End If End Sub
Private Sub PlaySoundAsFile(fName As String, Optional Wait As Boolean = False) Dim Flags As Long
Flags = SND_NODEFAULT Or SND_FILENAME Or SND_SYNC If Wait = False Then Flags = Flags Or SND_ASYNC PlaySoundA fName, 0&, Flags End Sub
Private Sub Command1_Click() PlaySoundAsFile "C:MonSon.wav" PlaySoundInMemory "MONSON" End Sub
-- Cordialement,
Jacques.
Bonjour Michel,
Michel a écrit :
Plutot EXECUTER un son ! je voulais dire...
Merci encore !
Suivant que ton son est dans un fichier, ou en mémoire(.res), tu peux
utiliser :
Private Declare Function sndPlaySound Lib "winmm.dll" Alias
"sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long
Private Declare Function PlaySoundA Lib "winmm.dll" (ByVal lpszName As
String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Dim m() As Byte
Public Sub PlaySoundInMemory(ResName, Optional Wait As Boolean = False)
Dim resErr As Long, Flags As Long
On Error Resume Next
Err.Clear
m = LoadResData(ResName, "WAVE")
resErr = Err.Number
If resErr = 0 Then
Flags = SND_NODEFAULT Or SND_MEMORY Or SND_SYNC
If Wait = False Then Flags = Flags Or SND_ASYNC
sndPlaySound m(0), Flags
End If
End Sub
Private Sub PlaySoundAsFile(fName As String, Optional Wait As Boolean =
False)
Dim Flags As Long
Flags = SND_NODEFAULT Or SND_FILENAME Or SND_SYNC
If Wait = False Then Flags = Flags Or SND_ASYNC
PlaySoundA fName, 0&, Flags
End Sub
Private Sub Command1_Click()
PlaySoundAsFile "C:MonSon.wav"
PlaySoundInMemory "MONSON"
End Sub
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long Private Declare Function PlaySoundA Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Dim m() As Byte
Public Sub PlaySoundInMemory(ResName, Optional Wait As Boolean = False) Dim resErr As Long, Flags As Long
On Error Resume Next Err.Clear m = LoadResData(ResName, "WAVE") resErr = Err.Number If resErr = 0 Then Flags = SND_NODEFAULT Or SND_MEMORY Or SND_SYNC If Wait = False Then Flags = Flags Or SND_ASYNC sndPlaySound m(0), Flags End If End Sub
Private Sub PlaySoundAsFile(fName As String, Optional Wait As Boolean = False) Dim Flags As Long
Flags = SND_NODEFAULT Or SND_FILENAME Or SND_SYNC If Wait = False Then Flags = Flags Or SND_ASYNC PlaySoundA fName, 0&, Flags End Sub
Private Sub Command1_Click() PlaySoundAsFile "C:MonSon.wav" PlaySoundInMemory "MONSON" End Sub