Solved

Detecting If CD Drive is open or closed

Posted on 1998-09-08
1
295 Views
Last Modified: 2012-05-04
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
Comment
Question by:Maxwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
movieguy earned 50 total points
ID: 1433751
' 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question