#include <windows.h>
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
   DWORD drives        = GetLogicalDrives();
   DWORD bit           = 0;
   char  driveLetter[] = "*:\\";

   if (!drives)
   {
      cout << "ERROR: GetLogicalDrives() failed with rc " <<
         GetLastError() << endl;
      return -1;
   }

   for (int i = 0, bit = 1; i != 26; i++, bit *= 2)
   {
      if (drives & bit)
      {
         cout << char('A' + i) << ": ";
         driveLetter[0] = 'A' + i;

         switch (GetDriveType(driveLetter))
         {
            case DRIVE_UNKNOWN:
               cout << "Unknown";
               break;
            case DRIVE_NO_ROOT_DIR:
               cout << "Invalid root path";
               break;
            case DRIVE_REMOVABLE:
               cout << "Removable";
               break;
            case DRIVE_FIXED:
               cout << "Fixed";
               break;
            case DRIVE_REMOTE:
               cout << "Remote";
               break;
            case DRIVE_CDROM:
               cout << "CD-ROM";
               break;
            case DRIVE_RAMDISK:
               cout << "RAM disk";
               break;
            default:
               cout << "??????";
               break;
         }

         cout << endl;
      }
   }

   cout << endl;

   return 0;
}
