In comp.os.ms-windows.programmer.tools, sp@cs.brown.edu (Seth Padowitz) writes:
>If you have Windows 3.1, then you can use the sndPlaySound() API
>from VB to play sounds through your soundblaster.
>Alternatively, you can use the Media Control Interface (MCI)
>Custom Control included in the VB Professional Toolkit to play
>sounds.
[... stuff deleted ...]
>You'll need to create a VB prototype for sndPlaySound(). My VB
>is a bit rusty, so I'll simply recommend that you look at your
>manual.
>Hope this helps.
>Seth
Hi Seth, good to see you again! I've had some requests for the VB
prototypes as well, so I'll post them here for anyone to use!!!
Note - these are NOT official MS prototypes! Use them, but at your
own risk... :-)
In the global declare....
Declare Function sndPlaySound Lib "MMsystem" (ByVal lpSound As String, ByVal Flags As Integer) As Integer
Global Const SND_SYNC = 0
Global Const SND_ASYNC = 1
In your program simply put...
Ret% = SndPlaySound("TADA.WAV", SND_ASYNC)
You can also access the MCI without the VB Pro Toolkit!! Much more flexible
but more difficult to use. You communicate with MCI via messages. The
alias is arbitrary, the ones I used below are for readability... A few
examples should get you going...
The VB prototypes are...
Declare Function mciSendString Lib "MMsystem" (ByVal lpCoMMand As String, ByVal lpReturnString As String, ByVal WReturnLength As Integer, ByVal hCallback As Integer) As Long
Declare Function mciGetErrorString Lib "MMsystem" (ByVa dwError As Long, ByVal lpBuffer As String, ByVal WReturnLength As Integer) As Integer
In your program to play TADA.WAV...
Ret% = mciSendString("Open TADA.WAV alias TALK");
Ret% = mciSendString("Play TALK");
Ret% = mciSendString("Close TALK");
to play "CANYON.MID":
Ret% = mciSendString("Open CANYON.MID alias MUSIC");