How can I open and close the CD-ROM drive?

If you would like to open or close the CD-Rom drive from Visual Basic, you can send a request to the Windows Multimedia DLL with the relevant command. You have to decare the DLL in your project.

Declarations

Copy this code into the declarations section of a module or form.

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

Procedure

To open the CD door, use this code:

retvalue = mcisendstring("set CDAudio door open", _
returnstring, 127, 0)

To close the CD door, use this code:

retvalue = mcisendstring("set CDAudio door closed", _
returnstring, 127, 0)


Compare Life Insurance | Arcade Games | Life Insurance Types | Blinds | Fun Animal Videos