How to play *.wav sounds from resource files
--------------------------------------------
The best way to play your wav sounds is to place them in a resource file
as custom resources and then use the PlaySound API to play them.This
allows you to group all your wavs and don't have to worry about filenames
and stuff and most importantly ,your users can't rip them off .
You can make resource files with the Resource Editor Add-In,available
on the Professional and Enterprise editions of VB5/VB6.Add all your
wav files in the resource file (as custom resources) and write down
their IDs .It's a good idea to have a constant for each wav in the 
resource file:

e.g.
Private Const WAV_SHOOT = 101
Private Const WAV_EXPLODE = 102

where 101 and 102 are the resource IDs of the shoot and explode wav
files.Then you have to add this code in your form or a standard module
(if you add it in a form you will have to change the scope of the
PlayResSoundData function to Private) .


'--------------------------------------------------------------------------
Option Explicit

Private Declare Function PlaySoundData Lib "winmm.dll" Alias "PlaySoundA" _
(lpData As Any, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private m_snd() As Byte

' flag values for uFlags parameter
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ALIAS_START = 0 ' must be > 4096 to keep strings in same section of resource file
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_VALID = &H1F ' valid flags /;Internal /
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_VALIDFLAGS = &H17201F ' Set of valid flag bits. Anything outside this range will raise error
Private Const SND_RESERVED = &HFF000000 ' In particular these flags are reserved
Private Const SND_TYPE_MASK = &H170007


Public Function PlayResSoundData(ByVal SndID As Long) As Long

      Const Flags = SND_MEMORY Or SND_ASYNC Or SND_NODEFAULT
      m_snd = LoadResData(SndID, "SOUND")
      PlaySoundData m_snd(0), 0, Flags

End Function

'--------------------------------------------------------------------------------

You will have to replace "SOUND" (in the PlayResSoundData function) with
whatever name you have given to your custom resource file data type.

After you add this code,you can play the wavs from your project's
resource file by simply calling the PlayResSoundData function:

PlayResSoundData WAV_SHOOT

where WAV_SHOOT is the resource ID of the wav file to play.

    Source: geocities.com/siliconvalley/network/5045

               ( geocities.com/siliconvalley/network)                   ( geocities.com/siliconvalley)