Close/open the CD Rom door

By | 2002-06-01

Open and close the CD rom door from code! Note:comment out the unneeded api declaration (16 or 32 bit) depending on what operating system you are using!

Original Author: Visual Basic On Line User Group

API Declarations

‘for 16 bit windows
Declare Function mcisendstring Lib “MMSystem” (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal wReturnLength As Integer, ByVal hCallback As Integer) As Long
‘Note:FOR 95/98/NT using the following:
Public 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

Code


'to open it:
x=
mciSendString("set cd door open", 0&,
0, 0)
'to close it:
x = mciSendString("set
cd door closed", 0&, 0, 0)

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.