Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long
Private Declare Function sndStopSound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszNull As Long, ByVal uFlags As Long) As LongPrivate Const SND_MEMORY = &H4
Private Const SND_SYNC = &H0
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Const SND_LOOP = &H8
Private Const SND_NOSTOP = &H10
Private Sub PlaySound(ind As Integer)
Dim r As Long
Dim uFlags As Long
uFlags = SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
r = sndStopSound(0, SND_ASYNC)
Select Case ind
Case 0 'Fire
r = sndPlaySound(arrFired(0), uFlags)
Case 1 'Shotted
r = sndPlaySound(arrBound(0), uFlags)
Case 2 'esNoBullet
r = sndPlaySound(arrNoBullet(0), uFlags)
End Select
End Function你可以把声音文件放到资源文件里面
在程序力读到数组里
用上面的函数就可以播放了
Private Declare Function sndStopSound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszNull As Long, ByVal uFlags As Long) As LongPrivate Const SND_MEMORY = &H4
Private Const SND_SYNC = &H0
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Const SND_LOOP = &H8
Private Const SND_NOSTOP = &H10
Private Sub PlaySound(ind As Integer)
Dim r As Long
Dim uFlags As Long
uFlags = SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
r = sndStopSound(0, SND_ASYNC)
Select Case ind
Case 0 'Fire
r = sndPlaySound(arrFired(0), uFlags)
Case 1 'Shotted
r = sndPlaySound(arrBound(0), uFlags)
Case 2 'esNoBullet
r = sndPlaySound(arrNoBullet(0), uFlags)
End Select
End Function你可以把声音文件放到资源文件里面
在程序力读到数组里
用上面的函数就可以播放了
【函数】
PlaySound【操作系统】
Win9X:Yes
WinNT:Yes【声明】
PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
--------------------------------------------------------------------
Made by Thirdapple's Studio(http://3rdapple.51.net/)
PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long