Re: Help with speaker code VB6



"Hugh Haggerty" <h.a.haggerty@xxxxxxxxxxxxx> wrote in message
news:Kf39f.2041$2y.1304@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> I need help with VB6 code to direct a WAV file
> to the computer speaker. Anyone know how to do
> this?

There are lots of different ways. The following is one of the simplest if
all you want is to play one wav file at a time:

Mike

Option Explicit
Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Private Declare Function waveOutGetNumDevs Lib "winmm" _
() As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

Private Sub Command1_Click()
Dim ret As Integer, flags As Integer
Dim soundfilename As String
soundfilename = "c:\windows\media\ding.wav"
flags = SND_ASYNC Or SND_NODEFAULT
ret = waveOutGetNumDevs()
If ret > 0 Then
ret = sndPlaySound(soundfilename, flags)
Else
MsgBox "NO SOUND DEVICE"
End If
End Sub




.



Relevant Pages