📄 mci.vb
字号:
'Command6
'
Me.Command6.BackColor = System.Drawing.SystemColors.Control
Me.Command6.Cursor = System.Windows.Forms.Cursors.Default
Me.Command6.Location = New System.Drawing.Point(143, 361)
Me.Command6.Name = "Command6"
Me.Command6.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command6.Size = New System.Drawing.Size(104, 29)
Me.Command6.TabIndex = 7
Me.Command6.Text = "Stop MID"
'
'Command5
'
Me.Command5.BackColor = System.Drawing.SystemColors.Control
Me.Command5.Cursor = System.Windows.Forms.Cursors.Default
Me.Command5.Location = New System.Drawing.Point(143, 194)
Me.Command5.Name = "Command5"
Me.Command5.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command5.Size = New System.Drawing.Size(104, 29)
Me.Command5.TabIndex = 1
Me.Command5.Text = "Stop WAV"
'
'Command4
'
Me.Command4.BackColor = System.Drawing.SystemColors.Control
Me.Command4.Cursor = System.Windows.Forms.Cursors.Default
Me.Command4.Location = New System.Drawing.Point(297, 361)
Me.Command4.Name = "Command4"
Me.Command4.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command4.Size = New System.Drawing.Size(99, 34)
Me.Command4.TabIndex = 10
Me.Command4.Text = "Play CD"
'
'Command3
'
Me.Command3.BackColor = System.Drawing.SystemColors.Control
Me.Command3.Cursor = System.Windows.Forms.Cursors.Default
Me.Command3.Location = New System.Drawing.Point(24, 47)
Me.Command3.Name = "Command3"
Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command3.Size = New System.Drawing.Size(104, 29)
Me.Command3.TabIndex = 2
Me.Command3.Text = "Play AVI"
'
'Command2
'
Me.Command2.BackColor = System.Drawing.SystemColors.Control
Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
Me.Command2.Location = New System.Drawing.Point(20, 361)
Me.Command2.Name = "Command2"
Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command2.Size = New System.Drawing.Size(104, 29)
Me.Command2.TabIndex = 6
Me.Command2.Text = "Play MID"
'
'Command1
'
Me.Command1.BackColor = System.Drawing.SystemColors.Control
Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
Me.Command1.Location = New System.Drawing.Point(20, 194)
Me.Command1.Name = "Command1"
Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command1.Size = New System.Drawing.Size(104, 29)
Me.Command1.TabIndex = 0
Me.Command1.Text = "Play WAV"
'
'Frame2
'
Me.Frame2.BackColor = System.Drawing.SystemColors.Control
Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.ProgressBar4})
Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Frame2.Location = New System.Drawing.Point(287, 342)
Me.Frame2.Name = "Frame2"
Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Frame2.Size = New System.Drawing.Size(370, 131)
Me.Frame2.TabIndex = 24
Me.Frame2.TabStop = False
Me.Frame2.Text = "CD Control"
'
'ProgressBar4
'
Me.ProgressBar4.Location = New System.Drawing.Point(16, 96)
Me.ProgressBar4.Maximum = 1
Me.ProgressBar4.Name = "ProgressBar4"
Me.ProgressBar4.Size = New System.Drawing.Size(344, 24)
Me.ProgressBar4.TabIndex = 0
'
'Frame3
'
Me.Frame3.BackColor = System.Drawing.SystemColors.Control
Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.ProgressBar1})
Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Frame3.Location = New System.Drawing.Point(10, 167)
Me.Frame3.Name = "Frame3"
Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Frame3.Size = New System.Drawing.Size(258, 140)
Me.Frame3.TabIndex = 25
Me.Frame3.TabStop = False
Me.Frame3.Text = "Wav Control"
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(8, 104)
Me.ProgressBar1.Maximum = 1
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(232, 24)
Me.ProgressBar1.TabIndex = 0
'
'Frame4
'
Me.Frame4.BackColor = System.Drawing.SystemColors.Control
Me.Frame4.Controls.AddRange(New System.Windows.Forms.Control() {Me.ProgressBar3})
Me.Frame4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Frame4.Location = New System.Drawing.Point(10, 333)
Me.Frame4.Name = "Frame4"
Me.Frame4.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Frame4.Size = New System.Drawing.Size(258, 140)
Me.Frame4.TabIndex = 26
Me.Frame4.TabStop = False
Me.Frame4.Text = "Midi Control"
'
'ProgressBar3
'
Me.ProgressBar3.Location = New System.Drawing.Point(8, 104)
Me.ProgressBar3.Maximum = 1
Me.ProgressBar3.Name = "ProgressBar3"
Me.ProgressBar3.Size = New System.Drawing.Size(232, 24)
Me.ProgressBar3.TabIndex = 0
'
'Frame5
'
Me.Frame5.BackColor = System.Drawing.SystemColors.Control
Me.Frame5.Controls.AddRange(New System.Windows.Forms.Control() {Me.ProgressBar2, Me.Command7})
Me.Frame5.ForeColor = System.Drawing.SystemColors.ControlText
Me.Frame5.Location = New System.Drawing.Point(10, 19)
Me.Frame5.Name = "Frame5"
Me.Frame5.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Frame5.Size = New System.Drawing.Size(258, 121)
Me.Frame5.TabIndex = 27
Me.Frame5.TabStop = False
Me.Frame5.Text = "AVI Control"
'
'ProgressBar2
'
Me.ProgressBar2.Location = New System.Drawing.Point(8, 88)
Me.ProgressBar2.Maximum = 1
Me.ProgressBar2.Name = "ProgressBar2"
Me.ProgressBar2.Size = New System.Drawing.Size(232, 24)
Me.ProgressBar2.TabIndex = 0
'
'Frame6
'
Me.Frame6.BackColor = System.Drawing.SystemColors.Control
Me.Frame6.ForeColor = System.Drawing.SystemColors.ControlText
Me.Frame6.Location = New System.Drawing.Point(287, 222)
Me.Frame6.Name = "Frame6"
Me.Frame6.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Frame6.Size = New System.Drawing.Size(370, 103)
Me.Frame6.TabIndex = 28
Me.Frame6.TabStop = False
Me.Frame6.Text = "CD To Wav"
'
'Timer2
'
Me.Timer2.Interval = 300
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(729, 500)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Picture1, Me.Command18, Me.Command17, Me.Command16, Me.Picture2, Me.Command14, Me.Command13, Me.Command12, Me.Command11, Me.Command10, Me.Command9, Me.Frame1, Me.Command8, Me.Command6, Me.Command5, Me.Command4, Me.Command3, Me.Command2, Me.Command1, Me.Frame2, Me.Frame3, Me.Frame4, Me.Frame5, Me.Frame6})
Me.Location = New System.Drawing.Point(110, 130)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
Me.Text = "MCI-MultiMediaPlayer"
Me.Frame2.ResumeLayout(False)
Me.Frame3.ResumeLayout(False)
Me.Frame4.ResumeLayout(False)
Me.Frame5.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
#Region "升级支持"
Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
Private Declare Function auxGetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByRef lpdwVolume As Integer) As Integer
Private Declare Function mciGetDeviceID Lib "winmm.dll" Alias "mciGetDeviceIDA"(ByVal lpstrName As String) As Integer
Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA"(ByVal wDeviceID As Integer, ByVal uMessage As Integer, ByVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA"(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Private Declare Function midiOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByRef lpdwVolume As Integer) As Integer
Private Declare Function midiOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByVal dwVolume As Integer) As Integer
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"(ByVal lpszSoundName As String, ByVal uFlags As Integer) As Integer
Private Declare Function waveOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByRef lpdwVolume As Integer) As Integer
Private Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByVal dwVolume As Integer) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Integer) As Integer
Private Structure lVolType
Dim v As Integer
End Structure
Private Structure VolType
Dim lv As Short
Dim rv As Short
End Structure
Const SM_CXBORDER As Short = 5
Const SM_CYBORDER As Short = 6
Const VK_SNAPSHOT As Byte = &H2Cs
Const SRCCOPY As Integer = &HCC0020
Const MCI_SET As Short = &H80Ds
Const MCI_SET_DOOR_OPEN As Integer = &H100
Dim WavFilename, MidFilename As Object
Dim AviFilename As String
Dim Timer2Counter As Integer
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click ' 播放Wav文件
Command5_Click(Command5, New System.EventArgs()) ' 播放Wav文件
Dim i, cb As Integer
Dim RS, W As String
RS = Space(128)
W = "e:\sound\demo1.wav"
i = mciSendString("open waveaudio!" & W & " alias sound", RS, 128, cb)
If i Then MsgBox("出错信息:MIDI文件可能不存在。请给出正确的文件名称。")
i = mciSendString("play sound", RS, 128, cb)
End Sub
Private Sub Command5_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command5.Click ' 停止播放Wav文件
Dim i, cb As Integer
Dim RS As String
RS = Space(128)
i = mciSendString("stop sound", RS, 128, cb)
i = mciSendString("close sound", RS, 128, cb)
End Sub
Private Sub Command11_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command11.Click ' 增大播放Wav的音量
Dim v, id, i As Integer
Dim lVol As lVolType
Dim Vol As VolType
Dim lv, rv As Double
id = -1
i = waveOutGetVolume(id, v)
lVol.v = v
Vol.lv = v : Vol.rv = v
lv = Vol.lv : rv = Vol.rv
lv = lv + &HFFF&
rv = rv + &HFFF&
If lv > 32767 Then lv = lv - 65536
If rv > 32767 Then rv = rv - 65536
Vol.lv = lv
Vol.rv = rv
lVol.v = Vol.rv
v = lVol.v
i = waveOutSetVolume(id, v)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -