CD Drive

does anyone have code to make a cd-rom drive open and close?

Comments

  • : does anyone have code to make a cd-rom drive open and close?
    :


    [code]
    Private Sub Command1_Click()
    CDControl True 'OPEN CD MANUALLY
    End Sub


    Private Sub Command2_Click()
    CDControl False 'CLOSE CD MANUALLY
    End Sub


    'CDControl Procedure - Place this code into the form of module where it is called
    Sub CDControl(ByVal action As Boolean)
    On Error GoTo erh

    If action Then 'open the CDROM
    retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0)
    Else 'close the CDROM
    retvalue = mciSendString("set CDAudio door closed", returnstring, 127, 0)
    End If
    Exit Sub

    erh:
    MsgBox Err.Description, vbCritical, Err.Number
    Resume Next
    End Sub



    'PUT IN MODULE-

    'Declare the following in the declarations section of your code
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion