Results 1 to 3 of 3

Thread: hopefully easy... BUT... might not be...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    1

    Cool

    Hi, :P
    ok how do u add a .wav file inside a .exe so it is not a seperate file that can be tampered with...
    then how do i play the file on request...?
    thanx in advance
    aSk_U

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Create a Resource File and add the WAV(s) to it with meaning full ID's, then use a modified version of the sndPlaySound() API to play them from memory, after loading the Resource WAV into a Binary Array, i.e.
    Code:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long
    Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    Private Const SND_ASYNC = &H1         '  play asynchronously
    
    Private Sub Command1_Click()
        Dim vSnd() As Byte
        vSnd = LoadResData("SOUND1", "CUSTOM")
        Call sndPlaySound(vSnd(0), SND_MEMORY Or SND_ASYNC)
    End Sub
    Regards,

    - Aaron.

  3. #3
    Guest
    playing the file, requires API


    Code:
    PlaySound "c:\my documents\Genflit0.wav", 0, d
    DoEvents
    I didnt exactly know what to put for the last option, so I just put an empty variable

    this will work, but first put this in a module

    Code:
    Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    Public Type WAVEFORMAT
            wFormatTag As Integer
            nChannels As Integer
            nSamplesPerSec As Long
            nAvgBytesPerSec As Long
            nBlockAlign As Integer
    End Type

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