[VB] vb 播放音乐

[复制链接]
梅雷工具箱发表于 2015-6-25 13:15:24 | 显示全部楼层 |阅读模式


播放音乐



'无需添加控件
'最简单的WAV声音或音乐文件播放的代码
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
Private Function PlayWavSound(SoundFile As String) As Long
Dim lFlags As Long
lFlags = SND_ASYNC Or SND_NODEFAULT
PlayWavSound = sndPlaySound(SoundFile, lFlags)
End Function
Private Function StopWavSound(SoundFile As String) As Long
Dim lFlags As Long
lFlags = SND_ASYNC Or SND_NODEFAULT
StopWavSound = sndPlaySound(SoundFile, lFlags)
End Function
'##################################
Private Sub Command1_Click()
Call PlayWavSound("C:\MeiLei_UG_WG\MeiLei_UG_WG\音\boink.wav")'调用方法【播放音乐】
End Sub

_____________________________________________________________________________ _

中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/
就上UG网淘宝直营店
您需要登录后才可以回帖 登录 | 注册UG网 用百度帐号登录

本版积分规则