Play WAV file who's data is strored in an EXE's resources
I've stored a WAV file in the resources of my program using VB6 resource editor. When compiled this data will be stored in the resources section of the EXE file. Now I know the API call Playsound is capable of playing WAV files. But my WAV file is now ACTUALLY IN the EXE file itself (complete WAV file header sound data etc, is all stored in the EXE file as binary resource data and can be seen if the EXE is opened in a hex editor). How do I play a WAV resource stored in the EXE file? Is there an API call for that? Please help.
Re: Play WAV file who's data is strored in an EXE's resources
You can extract and play it.
Code:
Public Sub ExtractFile(ByVal sPath As String)
Dim bytData() As Byte
ReDim bytData(Len(LoadResData(101, "CUSTOM")))
bytData = LoadResData(101, "CUSTOM")
Open sPath For Binary Access Write As #1
Put #1, , bytData
Close #1
End Sub
Sample usage:
Code:
ExtractFile "C:\test.wav"
Re: Play WAV file who's data is strored in an EXE's resources
You can also play WAV from an array and do not need to write it to file. Search for APIs PlaySound & sndPlaySound for examples.