VB如何在加载窗体时同时加载音乐!
VB如何在加载窗体时同时加载音乐.
模块代码:
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Function PlaySound(File As String)
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
wFlags% = SND_ASYNC Or SND_NODEFAULT
Svar = sndPlaySound(App.Path & "\" & File & ".wav", wFlags%)
End Function
窗体代码:
Private Sub Form_Load()
PlaySound "文件名(不带扩展名)"
End Sub