Solved

Res File

Posted on 2000-03-07
2
166 Views
Last Modified: 2010-05-02
How to play a wav from res file?
0
Comment
Question by:EasyCoder
2 Comments
 
LVL 13

Accepted Solution

by:
crazyman earned 150 total points
ID: 2592015
#If Win32 Then
Private Declare Function sndPlaySound Lib "winmm" Alias _
   "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) _
   As Long
#Else
Private Declare Function sndPlaySound Lib "MMSYSTEM" ( _
                   lpszSoundName As Any, ByVal uFlags%) As Integer
#End If

' Flag values for wFlags parameter.

'*********************************************************************

Public Const SND_SYNC = &H0        ' Play synchronously (default).
'Public Const SND_ASYNC = &H1      ' Play asynchronously (see
                            ' note below).
Public Const SND_NODEFAULT = &H2   ' Do not use default sound.
Public Const SND_MEMORY = &H4      ' lpszSoundName points to a
                            ' memory file.
Public Const SND_LOOP = &H8        ' Loop the sound until next
                            ' sndPlaySound.
Public Const SND_NOSTOP = &H10     ' Do not stop any currently
                                                  ' playing sound.
Public Sub PlayWaveRes(vntResourceID As Variant, Optional vntFlags)
'-----------------------------------------------------------------
' WARNING:  If you want to play sound files asynchronously in
'           Win32, then you MUST change bytSound() from a local
'           variable to a module-level or static variable. Doing
'           this prevents your array from being destroyed before
'           sndPlaySound is complete. If you fail to do this, you
'           will pass an invalid memory pointer, which will cause
'           a GPF in the Multimedia Control Interface (MCI).
'-----------------------------------------------------------------
Dim bytSound() As Byte ' Always store binary data in byte arrays!

bytSound = LoadResData(vntResourceID, "WAVE")

If IsMissing(vntFlags) Then
   vntFlags = SND_NODEFAULT Or SND_SYNC Or SND_MEMORY
End If

If (vntFlags And SND_MEMORY) = 0 Then
   vntFlags = vntFlags Or SND_MEMORY
End If

sndPlaySound bytSound(0), vntFlags
               End Sub
0
 

Author Comment

by:EasyCoder
ID: 2592025
Wow Fast ..thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now