PDA

Click to See Complete Forum and Search --> : Using VB resources with API


testman57
Oct 2nd, 2000, 07:14 AM
I'm actually wondering on how I could make sounds fit into the exe file of VB progs : I thought I could use the resource system, but I have now another problem: How could I access this resources with api , like PlaySound, or MsgboxIndirect(for the Icon), knowing the Res ID (101.. in my case) ? I tried using the SND_RESOURCE with PlaySound, but it doesn't play my sound , but only the default sound !

If someone could help me...


TestMan57, France

hitcgar
Oct 2nd, 2000, 08:44 AM
I would suggest that you store the sound file in your
resource then use the LoadResData function to load it into
a byte array.

Once you have it in memory, save the byte array's contents
to a disk file and then play it using either a mediaplayer
control or directly through the MCI API - specifying the disk file to use.

to save a byte array to disk:

' ---------------------------------------------------------------------------
' Write byte array to file
' ---------------------------------------------------------------------------
Dim intFile As Integer
Dim bytData() As Byte
Dim strFile As String

strFile = "filename.wav" ' for example

intFile = FreeFile
Open strFile For Binary Access Write As #intFile
Put #intFile, , bytData()
Close #intFile


This also works on avi's and other less 'standard'
resources (i.e. not icon, bmp, menu, etc.)

If someone has a better way I too am interested.

have fun ;)