Getting list of CD-ROM drives

Does anyone know how to get a list of drive letters for all the CD-ROM drives under Windows 95 using VC6?

Can't seem to find anything in MSDN...

Who is Participating?
nietodConnect With a Mentor Commented:
Use GetLogicalDrives() and GetDriveType()

details follow.
GetLogicalDrives() returns a 32 bit value (DWORD) that is a bitmask of the drives that are defined on the computer.  each bit that is set to 1 indicates a drive that is defined.  i.e if the low bit is set, then there is a drive A and so on.  Use this to determine what drive letters are available.

Once you know what drive letters are available, use GetDriveType() to determine which of those drives are a CDROM.  It returns DRIVE_CDROM for a cd ROM.

DWORD DrvMsk = GetLogicalDrives();
char DrvLtr;
char DrvPth = "A:\\";

for (DrvLtr = 'A'; DrvLtr <= 'Z'; ++DrvLtr) // For each letter.
   if (DrvMsk & 1) // If drive is defined, then
       DrvPth[0] = DrvLtr; // Store drive letter in path string.
       if (GetDriveType(DrvPth) ==  DRIVE_CDROM)
   DrvMsk >>= 1; // shift next bit to low bit.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.