GetRemovableDrives()

2009. 11. 27. 14:09 from 셈말짓기/Windows


 void GetRemovableDrives (std::vector<std::wstring>& logicalDrives)
 {
  TCHAR  buf[512];
  TCHAR* rootPathName = buf;
  BOOL   hasVolumeInfo;
  UINT   driveType;


  if (0==GetLogicalDriveStrings (512-1, buf))
   return;

  do
  {
   driveType     = GetDriveType (rootPathName);
   hasVolumeInfo = GetVolumeInformation (rootPathName,
              NULL, 0,
              NULL, NULL, NULL,
              NULL, 0);
   if (driveType==DRIVE_REMOVABLE && hasVolumeInfo==TRUE)
   {
    logicalDrives.push_back (std::wstring (rootPathName) );
   }
   while (*rootPathName++);
  } while (*rootPathName);
 }

Posted by 셈말짓기 :