Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detecting If CD Drive is open or closed

Posted on 1998-09-08
1
Medium Priority
?
308 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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

719 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