Option Explicit
Private Type MCI_OPEN_PARMS
dwCallback As Long
wDeviceID As Long
lpstrDeviceType As String
lpstrElementName As String
lpstrAlias As String
End Type
Private Const MCI_OPEN = &H803
Private Const MCI_OPEN_TYPE = &H2000&
Private Const MCI_SET = &H80D
Private Const MCI_SET_DOOR_OPEN = &H100&
Private Const MCI_SET_DOOR_CLOSED As Long = &H200&
Private Const MCI_CLOSE = &H804
Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByRef dwParam2 As Any) As Long
Private openParams As MCI_OPEN_PARMS
Private Sub Form_Load()
openParams.wDeviceID = 0
openParams.lpstrDeviceType = "cdaudio"
Call mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE, openParams)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mciSendCommand(openParams.wDeviceID, MCI_CLOSE, 0, ByVal 0&)
End Sub
Private Sub cmdApriCD_Click()
Call mciSendCommand(openParams.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, ByVal 0&)
End Sub
Private Sub cmdChiudiCD_Click()
Call mciSendCommand(openParams.wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, ByVal 0&)
End Sub