sound in vb

im using the mci32 control to play sound in my vb app, but is there a way of playiing sound where this file doesnt have to be included in the set up of this app.  can i use windows inbuilt dll to do it.  or is the multimedia control the best im gonna get?
LVL 2
gerrymcdAsked:
Who is Participating?
 
plasmatekConnect With a Mentor Commented:
Make a bas file and put the following in it:

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

Public Function PlayWav(wavefile As String) As boolean
    Dim lRet As Long
    lRet = sndPlaySound(wavefile, &H1 Or &H2)
End Function


then call the function like this:

dim DidItWork as boolean
DidItWork = playwav("c:\windows\media\ding.wav")





Diditwork will be false if the sound didn't play due to an error, and true if it did work. Accept this comment as an answer if it works.
0
 
plasmatekCommented:
sorry...
change:
dim lret as long
to:
dim lret as boolean
0
 
AzraSoundCommented:
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
jsimonh33Commented:
It sounds like you are trying to embed the sound in your program. Is that your goal?

Simon
0
 
gerrymcdAuthor Commented:
ill try the plastek, but will all users who download the prog hadve this dll file.  is there a version which they should have for it to work?
0
 
AzraSoundCommented:
the package and deployment wizard will take care of everything for you.  
0
 
gerrymcdAuthor Commented:
ok plasteks sol worked but all activiies on the form stop when ts playing a sound, anyway to stop this?
0
 
gerrymcdAuthor Commented:
nie spot on it works perfectly
0
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.