如何在 VB 中播放声音文件 |
Sub PlayWav(SoundName As String) Dim tmpSoundName As String Dim wFlags%, X% , 声明语句部分 (请置于模块中) ,********************************** ,#If Win32 Then ,Public Declare Function sndPlaySound& Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) ,#Else ,Public Declare Function sndPlaySound% Lib "mmsystem.dll" (ByVal lpszSoundName As String, ByVal uFlags As Integer) ,#End If ,WIN32 , ********************************** , WAV Sound values ,Global Const SND_SYNC = &H0 ,Global Const SND_ASYNC = &H1 ,Global Const SND_NODEFAULT = &H2 ,Global Const SND_LOOP = &H8 ,Global Const SND_NOSTOP = &H10 , ********************************** , *** pathWavFiles 是声音文件存放的路径 tmpSoundName = pathWavFiles & SoundName wFlags% = SND_ASYNC Or SND_NODEFAULT X% = sndPlaySound(tmpSoundName, wFlags%) End Sub |