Results 1 to 2 of 2

Thread: Embed wav file

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    How can I embed a wav file into a program? How could I have the sound play when the program loads? I don't want to include the wav file as an extra file, I would rather have it in the executable.

    Thanks
    <removed by admin>

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can have a resource file with your WAV in it. Then on a form load you can load the sound from there:
    Code:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Const SND_ASYNC = &H1
    Private Const SND_NODEFAULT = &H2
    Private Const FLAGS = SND_ASYNC And SND_NODEFAULT
    
    
    Public Sub PlayWavResource(pintResourceID As Integer)
        Dim strSoundBuffer As String
    
        strSoundBuffer = StrConv(LoadResData(pintResourceID, "CUSTOM"), vbUnicode)
        Call sndPlaySound(strSoundBuffer, FLAGS)
    End Sub
    
    
    Private Sub Form_Load()
        'Assuming that 101 is an ID for the resource
        PlayWavResource 101
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width