Link to home
Start Free TrialLog in
Avatar of Gumpy
Gumpy

asked on

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...

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

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.

continues.
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)
          DoSomething();
   }
   DrvMsk >>= 1; // shift next bit to low bit.
}