点击vb菜单-工具-资源编辑器,用鼠标拉宽,倒数第二个按钮,把你的wav文件添加进去,类型名为"WAVE",标识号为"MySound",注意都要带上双引号,然后保存资源文件,例子代码如下:
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
我回答过N次这样的问题,难道你搜不到么