Embaed a .wav file, possible?

Embaed a .wav file, possible?

Post by land » Tue, 02 Dec 2003 12:24:36

I have a program that presents a version of a metronome. The program plays
repeatedly (at different rates) a .wav file. I do that with the
sndPlatSound api call, and figured out how to read the .wav into memory
and play it from there, to be a little more efficient. My question is, is
there some way I can embed the .wav file in the .exe so I don't need to
have it available seperately?

Thanks much,
Larry L

Embaed a .wav file, possible?

Post by fajp » Tue, 02 Dec 2003 12:34:41

On Mon, 01 Dec 2003 03:24:36 GMT, XXXX@XXXXX.COM (Larry

Look at using a resource file, but IIRC, it has a limit of 65Ks.
If that does suffice, then you could save the wave as a custom
resource, then load it with LoadResData into a byte array, then send
that on to sndPlaySound.

Look at the Add-In manager, make sure that Resource editor is loaded,
then right click on your project and select "add resource file".
Give it a name etc... then double click the file in your project pane,
the rest is relatively straight forward.. but Help will help. :-)
The resource file will be embedded into the executable when compiled.



Regards, Frank


Embaed a .wav file, possible?

Post by BeastFis » Tue, 02 Dec 2003 13:54:07

To add to Frank's reply, check out this link:



Embaed a .wav file, possible?

Post by BeastFis » Tue, 02 Dec 2003 14:00:29

Ack! That link word-wrapped horrendously :-(

Oh well... here's the code I posted in that link for playing a resource file

Dim sMySound As String, rs As Long

' Load sound from resource, Unicode convert
sMySound = StrConv(LoadResData(16, "MYSOUND"), vbUnicode)

' Then to play it...
rs = sndPlaySoundA(sMySound, &H1 Or &H2 Or &H4) 'Async & from memory



Embaed a .wav file, possible?

Post by Ronal » Tue, 02 Dec 2003 23:37:54


After you compiled an exe-file you can put anything you like behind the
exefile. The exe-file will always work. So just open de .exe-file (in with
another VB-program) for binary, seek to the end of the file, put a mark
there like [HERE_STARTS_MY_WAVE_FILE] and then putin the wave file. At
runtine you can read the file from the exe-file.



Embaed a .wav file, possible?

Post by land » Wed, 03 Dec 2003 13:25:43

Thanks to all you guys, I have never used a Resource file, but will give
it a shot!

Larry L

In article <bqeht3$21vat1$ XXXX@XXXXX.COM >, "BeastFish"