VB 提供的方法使我们可以很容易地使用资源文件中的字符、图片等资源。我们可以用以下方法播放资源文件中的 wav 声音: 首先,在你的资源文件的源文件 (RC) 文件加入下面一行:
MySound WAVE c:\music\vanhalen.wav
然后将其编译为 RES 文件。最后使用下面的声明及代码:

Private Declare Function PlaySound Lib _ "winmm.dll" Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Private Const SND_ASYNC& = &H1
Private Const SND_NODEFAULT& = &H2
Private Const SND_RESOURCE& = &H40004
Dim hInst As Long
Dim sSoundName As String
Dim lFlags As Long
Dim lRet As Long
Private Sub Command1_Click()
hInst = App.hInstance
sSoundName = "MySound"
lFlags = SND_RESOURCE + SND_ASYNC + _ SND_NODEFAULT
lRet = PlaySound(sSoundName, hInst, lFlags)
End Sub