织梦CMS - 轻松建站从此开始!

罗索

当前位置: 主页>老古董>VB>

使用sndPlaySound播放声音

罗索客 发布于 2001-11-20 23:47 点击:次 
[声明API函数] Private Declare Function sndPlaySound Lib winmm.dll Alias sndPlaySoundA (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Declare Function mciSendString Lib winmm.dll Alias mciSendStringA (ByVal lpstrCommand As Strin
TAG:

[声明API函数]
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
'播放WAV所需要的声明
'检测声卡所需要的声明
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Declare Function auxGetNaumDevs Lib "MMSYSTEM.dll″()as Integer" ()

'所用到的全局变量声明
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ALIAS_START = 0 ' must be > 4096 to keep strings in same section of resource file
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESERVED = &HFF000000 ' In particular these flags are reserved
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Const SND_TYPE_MASK = &H170007
Private Const SND_VALID = &H1F ' valid flags / ;Internal /
Private Const SND_VALIDFLAGS = &H17201F ' Set of valid flag bits. Anything outside

'3.在Form1上添加一个命令按钮控件,采用缺省的方法建立Command1。
'将它的Caption属性设置为“播放文件”。
'4.将如下的代码添加到Command1的单击事件中:
Private Sub Comman2_Click()
CmdStr$ = "play c:\\Cbt_demo.avi fullscreen "
ReturnVal& = mciSendString(CmdStr$, 0&, 0, 0&)
End Sub


Private Sub Command1_Click()
Dim Flag As Long
Dim a As Long
Flag = SND_ASYNC Or SND_LOOP
Print Flag
a = sndPlaySound("c:\\02.wav", Flag)
End Sub

Private Sub Command3_Click()
Dim Flag As Long
Dim a As Long
Flag = SND_ASYNC
Print Flag
a = sndPlaySound("c:\\a.wav", Flag)
End Sub (iwgh)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/unsort/vb/2001/1120/53.html]
本文出处: 作者:iwgh
顶一下
(2)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片