Re: Help with speaker code VB6
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Oct 2005 18:56:18 -0000
"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
.
- Follow-Ups:
- Re: Help with speaker code VB6
- From: Hugh
- Re: Help with speaker code VB6
- References:
- Help with speaker code VB6
- From: Hugh Haggerty
- Help with speaker code VB6
- Prev by Date: Re: Bogged down on things
- Next by Date: Re: Bogged down on things
- Previous by thread: Help with speaker code VB6
- Next by thread: Re: Help with speaker code VB6
- Index(es):
Relevant Pages
|