MCISendString (wav)

I'm wondering how to play a wav file, i've read that we need mciSendString API.

I wrote this code in a module and wondering if it's the good one or we have to use something else...

Declare Function sndPlaysound Lib "winmm.lib" (ByVal pszSound As String, _
ByVal hmod As Any, ByVal fdwsound As Any) As Long

Thank you in advance for your time
Who is Participating?
koomConnect With a Mentor Commented:
If you want to play a wav file do this

' In the Declarations of one form

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_ASYNC = &H1

' Insert a Command Button

Private Sub Command1_Click()
filename = "c:\sound.wav"  
'type this to play the sound
sndPlaySound filename, SND_ASYNC

End Sub



lutharAuthor Commented:
Ok this is great but is there a way to close it :D let's say when i click on command2...

Thanks :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.