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
Solved

Detecting If CD Drive is open or closed

Posted on 1998-09-08
1
266 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA : retain and exclude values based on a config sheet and multiple parameters 5 62
using Access 8 75
VB6 - Compare and highlight cell not the same 3 53
Problem to line 23 53
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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