Option Explicit
'source : http://www.freevbcode.com/ShowCode.asp?ID=68
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
pstrReturnString As String, ByVal uReturnLength As Long, ByVal _
wndCallback As Long) As Long
Sub OpenOrShutCDDrive(DoorOpen As Boolean)
Application.OnTime Now + TimeValue("0:30:00"), "OpenCD"
Dim lRet As Long
If DoorOpen Then
lRet = mciSendString("Set CDAudio Door Open", 0&, 0&, 0&)
MsgBox ("Please Play Better Music")
Else
lRet = mciSendString("Set CDAudio door closed", 0&, 0&, 0)
End If
'lRet will = 0 upon success, so if you want to make this
'a function, return true if lret = 0, false otherwise
End Sub
Sub OpenCD()
OpenOrShutCDDrive (1)
End Sub
Sub CloseCD()
OpenOrShutCDDrive (0)
End Sub