填加一个 Command控件就可以 将其改为 打开光驱即可.然后填加代码
代码如下:
---------------
Option Explicit
Private Declare Function CD Lib "winmm.dll" Alias "mciSendStringA" _
( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As Long _
) As Long
'这里的CD你可以改成其他名字
'这是mci指令编程 在vc中除了要包含相应头文件
'还要申明使用的dll库的 即加上#pragma comment(lib, "winmm.lib")
Dim CDOpen As Boolean
Private Sub Command1_Click()
On Error Resume Next
If CDOpen = False Then
Call CD("set CDAudio door open", 0, 0, 0)
CDOpen = True
Command1.Caption = "关闭光驱"
Else
Call CD("set CDAudio door closed", 0, 0, 0)
CDOpen = False
Command1.Caption = "打开光驱"
End If
End Sub
Private Sub Form_Load()
CDOpen = False
Call CD("set CDAudio door closed", 0, 0, 0)
End Sub
----------------------------
很简单的一个小程序 !有兴趣的可以试下