Opening/Closing of CD Drive ( Linux & VB )

Post date: 04-May-2010 07:47:10

In Linux, from the command line:

To open the drive:

eject DriveNameHere

To close the drive:

eject -t DriveNameHere

If your not sure what the drive name is, just look in /etc/fstab:

cat /etc/fstab

In my case I would use:

eject /media/cdrom

and

eject -t /media/cdrom

Opening and closing of the CD drive can be achieved easily in visual basic by the following code

Private 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

Dim strReturn As String

Public Sub OpenCDDrive() 'Call me to open the CD Drive

Call mciSendString("set CDAudio door open", strReturn, 127, 0)

End Sub

Public Sub CloseCDDrive() 'Call me to close the CD Drive

Call mciSendString("set CDAudio door closed", strReturn, 127, 0)

End Sub