MCI Supports Multiple CD-ROMs

The Media Control Interface (MCI) can easily support multiple CD audio devices.
You simply specify the drive letter in the MCI open command. To eject the CD from any drive,
first place a listbox on a form. To detect which drives are CD-ROMs,
place this code in the form’s General Declarations section:

 Private Declare Function GetDriveType Lib _	"kernel32" Alias "GetDriveTypeA" (ByVal _	nDrive As String) As LongPrivate 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 LongPrivate Const DRIVE_CDROM = 5

The following code in the Form_Load event fills the listbox with available CD-ROM drives.
Note that the code does not detect whether the CD-ROM drive can actually eject the CD.
Use the “capabilities can eject” MCI command to determine that:

 Private Sub Form_Load()	Dim k As Long	For k = Asc("A") To Asc("Z")		If GetDriveType(Chr$(k) & ":") = _			DRIVE_CDROM Then			List1.AddItem Chr$(k) & ":"		End If	NextEnd Sub

Place this code in the List1_DblClick event to eject the CD:

 Private Sub List1_DblClick()	mciSendString "open " & _		List1.List(List1.ListIndex) & _		" type cdaudio alias cdaudio", _		vbNullString, 0, 0	mciSendString "set cdaudio door open", _		vbNullString, 0, 0	mciSendString "close cdaudio", vbNullString, _		0, 0End Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS