出自zhaosihua编的Swinapi软件
'This project needs :
'- a common dialog box, named Cdbox
' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
' and select Microsoft Common Dialog control)
'-a button
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Private Sub Command1_Click()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Get the number of installed waveout devices
ret& = waveOutGetNumDevs
If ret& > 0 Then
'Set the CommonDialogBox' filter
CDBox.Filter = "Wave-files (*.wav)|*.wav|All Files (*.*)|*.*"
'Set the CommonDialogBox' title
CDBox.DialogTitle = "Choose your wave-file ..."
'Show the 'Open File'-dialog
CDBox.ShowOpen
'Play the selected sound
sndPlaySound CDBox.filename, SND_ASYNC Or SND_NODEFAULT
Else
MsgBox "No soundcard detected !"
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "Load WAV"
End Sub
'This project needs :
'- a common dialog box, named Cdbox
' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
' and select Microsoft Common Dialog control)
'-a button
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Private Sub Command1_Click()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Get the number of installed waveout devices
ret& = waveOutGetNumDevs
If ret& > 0 Then
'Set the CommonDialogBox' filter
CDBox.Filter = "Wave-files (*.wav)|*.wav|All Files (*.*)|*.*"
'Set the CommonDialogBox' title
CDBox.DialogTitle = "Choose your wave-file ..."
'Show the 'Open File'-dialog
CDBox.ShowOpen
'Play the selected sound
sndPlaySound CDBox.filename, SND_ASYNC Or SND_NODEFAULT
Else
MsgBox "No soundcard detected !"
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "Load WAV"
End Sub
解决方案 »
- 大侠帮助,如何取一串数字的后几位?
- taoheping来接分!
- VB开发是不是要记住很多那些繁烦的API函数啊??
- 紧急求助,向数据库中导数据出错的问题
- 1996年人口12.4亿,每年增长0.3%,哪年增长到16亿?
- 请教,如何将人民币小写转换为大写,需要考虑很多种情况
- dll问题!在线等
- 使用OLE控件怎样链接任何目录下的powerpoint文件,100分
- 如何在vb中打开已加密的ACCESS文件?
- 请问为何在装有Office或IE5.0以上的机器中安装VB6.0,在VB中的一些地方无法正常现实中文,该怎样解决?
- 那位任兄能提供关于WINSOCK的文章或是相关书籍。
- 如何配置远程的COM+,类似DCOM。
Dim i As Integer, worked As Integer
For i = 0 to UBound(WaveFiles)
worked = sndPlaySound(WaveFiles(i), 0)
Next i