|
楼主 |
发表于 2024-6-8 09:54
|
显示全部楼层
本帖最后由 jaxxcyh 于 2024-6-10 22:09 编辑
写了个赛诗会的摇号程序,点击按钮时需要有音效,所以需要用到这个循环播放声音都代码。
lss001 写的常量声明放进去马上就行了。(我原来写的可能写错了所以一直没弄出循环的效果,感谢 lss001 帮我)
另外播放声音的windows API函数,可以用PlaySound函数,也可以用sndPlaySound函数。
这两个函数的声明部分大体上差不多,前者带三个参数,后者带两个参数。
'PlaySound函数的声明:
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal pszSoundName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
'sndPlaySound函数的声明:
Private Declare PtrSafe 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_MEMORY = &H4
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Const SND_PURGE = &H40
Const SND_NOWAIT = &H2000
Const SND_ALIAS = &H10000
Const SND_ALIAS_ID = &H110000
Const SND_FILENAME = &H20000
Const SND_RESOURCE = &H40004
'指定文件名,异步方式,循环播放:
PlaySound "d:\di.wav", 0, SND_FILENAME Or SND_ASYNC Or SND_LOOP
'也可以直接写成:
PlaySound "d:\di.wav", 0, &H20009 '(SND_FILENAME Or SND_ASYNC Or SND_LOOP 位或运算的结果就是&H20009)
'停止播放:
PlaySound vbNullString, 0, SND_PURGE
附上完整“赛事会摇号程序”文件
|
评分
-
1
查看全部评分
-
|