"winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_SYNC = &&H0
Const SND_ASYNC = &&H1
Const SND_NODEFAULT = &&H2
Const SND_MEMORY = &&H4
Const SND_ALIAS = &&H10000
Const SND_FILENAME = &&H20000
Const SND_RESOURCE = &&H40004
Const SND_ALIAS_ID = &&H110000
Const SND_ALIAS_START = 0
Const SND_LOOP = &&H8
Const SND_NOSTOP = &&H10
Const SND_VALID = &&H1F
Const SND_NOWAIT = &&H2000
Const SND_VALIDFLAGS = &&H17201F
Const SND_RESERVED = &&HFF000000
Const SND_TYPE_MASK = &&H170007
Private Declare Function mciExecute Lib "winmm.dll" Alias "mciExecute" (ByVal lpstrCommand As String) As Long
2、在窗中激活事件中加入以下代码:
Private Sub Form_Activate()
Dim ReturnValue As Long
ReturnValue = sndPlaySound("C:windowsMEDIATADA.WAV",SND_SYNC)End Sub
通过(F5)键来运行该程度即可听到背景音乐。