Solved

Res File

Posted on 2000-03-07
2
175 Views
Last Modified: 2010-05-02
How to play a wav from res file?
0
Comment
Question by:EasyCoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

735 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