Solved

Res File

Posted on 2000-03-07
2
181 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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