这个函数怎么用啊?

violetfy 2003-11-18 06:00:37
我记得有API函数可以直接播放指定路径的wav文件,谁知道具体这个函数怎么写,尤其是各个参数怎么用,请讲的透彻一点哦!
...全文
56 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
orcale 2003-11-18
  • 打赏
  • 举报
回复
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
?lpszSound
A string that specifies the sound to play. This parameter can be either an entry in the registry or in WIN.INI that identifies a system sound, or it can be the name of a waveform-audio file. (If the function does not find the entry, the parameter is treated as a filename.) If this parameter is NULL, any currently playing sound is stopped.

?fuSound
Flags for playing the sound. The following values are defined:
SND_ASYNC
The sound is played asynchronously and the function returns immediately after beginning the sound. To terminate an asynchronously played sound, call sndPlaySound with lpszSoundName set to NULL.
SND_LOOP
The sound plays repeatedly until sndPlaySound is called again with the lpszSoundName parameter set to NULL. You must also specify the SND_ASYNC flag to loop sounds.
SND_MEMORY
The parameter specified by lpszSoundName points to an image of a waveform sound in memory.
SND_NODEFAULT
If the sound cannot be found, the function returns silently without playing the default sound.
SND_NOSTOP
If a sound is currently playing, the function immediately returns FALSE, without playing the requested sound.
SND_SYNC
The sound is played synchronously and the function does not return until the sound ends.

'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: KPDTeam@Allapi.net
'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
szyhy810518 2003-11-18
  • 打赏
  • 举报
回复

Public Const S_PWAV_NEW = 1

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

sndPlaySound “文件",S_PWAV_NEW

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧