Option Explicit
Private Declare Function midiOutOpen Lib "winmm" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Private Declare Function midiOutClose Lib "winmm" (ByVal hMidiOut As Long) As Long
Private Declare Function midiOutShortMsg Lib "winmm" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'参考资料一:https://tieba.baidu.com/p/7232176258
'参考资料二:https://blog.csdn.net/vcacc/article/details/17787239
'参考资料三:生日快乐歌简谱
Dim I As Integer, hMO As Long, YueQi As Long
Dim A As Long, j As Long, k As Long
Private Sub Form_Activate()
Me.AutoRedraw = False
Me.FontSize = 15
Me.Print "模拟音效播放ing"
DoEvents
j = 1
k = 5
If midiOutOpen(hMO, -1&, 0&, 0&, 0&) Then Exit Sub
midiOutShortMsg hMO, &HC0& Or (26 * &H100&)
A = &H7F3990
'ret=midiOutShortMsg(midiout, &H90 + ((flip) * &H100) + (volume * &H10000) + channel)
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &H600 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H800 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H700 * j: Sleep 200 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &H600 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H900 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H800 * j: Sleep 200 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &H500 * j: Sleep 50 * k
midiOutShortMsg hMO, A + &HC00 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &HA00 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H800 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H700 * j: Sleep 100 * k
midiOutShortMsg hMO, A + &H600 * j: Sleep 100 * k
midiOutClose hMO
Me.Print "模拟音效播放完毕"
End Sub