📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "控制光驱的开关"
ClientHeight = 2856
ClientLeft = 48
ClientTop = 336
ClientWidth = 4848
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2856
ScaleWidth = 4848
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出程序"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 840
TabIndex = 1
Top = 1440
Width = 2652
End
Begin VB.CommandButton Command1
Caption = "点击打开光驱"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 840
TabIndex = 0
Top = 720
Width = 2652
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'-------------------------------------------
Option Explicit
Private Declare Function CDdoor Lib "winmm.dll" Alias "mciSendStringA" _
( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As Long _
) As Long
'CDOpen用来标示光驱开与关的状态
Dim CDOpen As Boolean
Private Sub Command1_Click()
On Error Resume Next
'如果关闭则打开,并且按钮做相应变化
If CDOpen = False Then
Call CDdoor("set CDAudio door open", 0, 0, 0)
CDOpen = True
Command1.Caption = "点击关闭光驱"
Else
'否则关闭
Call CDdoor("set CDAudio door closed", 0, 0, 0)
CDOpen = False
Command1.Caption = "点击打开光驱"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
CDOpen = False
Call CDdoor("set CDAudio door closed", 0, 0, 0)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -