devxlogo

Calling the CD-Rom

Calling the CD-Rom

Question:
I would like to know how to call the CD-Rom, or rather search for its drive letter.

Answer:
You can use the FileSystemObject (Microsoft Scripting Runtime in the references dialog). Iterate through the Drives collection of the FileSystemObject and check its DriveType property and DriveLetter property. DriveType 4 is the CD ROM.

Set a reference to the Microsoft Scripting Runtime and try this code.

Dim objFso As New FileSystemObjectDim objDrive As DriveFor Each objDrive In objFso.Drives    With objDrive        If .DriveType = CDRom Then            MsgBox "CD ROM is " & .DriveLetter        End If    End WithNext objDrive
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist