Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

Detecting If CD Drive is open or closed

I need to know how to detect if the CDrom drive is open or closed, and have it return a value, so a different picture can be displayed, depending on the cdtrays status.
0
Maxwell
Asked:
Maxwell
1 Solution
 
movieguyCommented:
' Code assumes VB5
' Add to a module
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


' To check if the door is closed and close it if
' it is not already closed.
Private Sub Command2_Click()
status = mciSendString("Set CDAudio Door Closed Wait", 0&, 0, 0)

    If (status <> 0) Then
        ' Do this code if the door is closed
        ' Display Closed CD Picture
    Else
        ' Do this code if the door is not closed
        ' Display Open CD Picture
    End If
End Sub

' A statement like the following will check if the door is open
' and open it if it is not
status = mciSendString("Set CDAudio Door Open Wait", 0&, 0, 0)

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now