Solved

Detecting If CD Drive is open or closed

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now