***********************************************************
* 转载请务必注明来源于 雨律在线 Http://YuLv.Net
***********************************************************

'最简单的WAV声音或音乐文件播放的代码
'API声明
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(
ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'常量
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

'播放WAV声音或音乐文件
Private Function PlayWavSound(SoundFile As String) As Long
'SoundFile 变量为存放WAV声音路径的
Dim lFlags As Long
lFlags = SND_ASYNC Or SND_NODEFAULT
PlayWavSound = sndPlaySound(SoundFile, lFlags)
End Sub

'停止播放WAV声音或音乐文件
Private Function StopWavSound(SoundFile As String) As Long
Dim
lFlags As Long
lFlags = SND_ASYNC Or SND_NODEFAULT
StopWavSound = sndPlaySound(SoundFile,lFlags)
End Sub



'调用例子
Call PlayWavSound("C:\WINDOWS\Media\Windows XP 电话拨入声.wav")



 
目前有0条回应
Comment
Trackback
你目前的身份是游客,请输入昵称和电邮!