void __fastcall TForm1::GetDriveInfo(void)
{
UINT Type;
String s;
char lpVolumeName[255], lpFileSystemName[100], szBuffer[512];
DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags;
//Clear the info display
mInfo->Clear();
//Get the drive type
Type = GetDriveType(cbPath->Items->Strings[cbPath->ItemIndex].c_str());
//Update the display accoring to the drive type
switch (Type)
{
case 0:
s = "Unknown";
break;
case 1:
s = "Does not exist";
break;
case DRIVE_REMOVABLE:
s = "Removable Disk Drive";
break;
case DRIVE_FIXED:
s = "Fixed Disk Drive";
break;
case DRIVE_REMOTE:
s = "Network Drive";
break;
case DRIVE_CDROM:
s = "CD ROM Drive";
break;
case DRIVE_RAMDISK:
s = "RAM Disk";
}
mInfo->Lines->Add("Device Type: " + s);
//Check the volume information. Returns TRUE on success
if (GetVolumeInformation(cbPath->Items->Strings[cbPath->ItemIndex].c_str(),
lpVolumeName,
255,
&dwVolumeSerialNumber,
&dwMaximumComponentLength,
&dwFileSystemFlags,
lpFileSystemName,
100))
{
//Update the display with the information
wsprintf(szBuffer, "Volume Name: %s", lpVolumeName);
mInfo->Lines->Add(szBuffer);
wsprintf(szBuffer, "Serial Number: %u", dwVolumeSerialNumber);
mInfo->Lines->Add(szBuffer);
wsprintf(szBuffer, "File System: %s", lpFileSystemName);
mInfo->Lines->Add(szBuffer);
}
//GetVolumeInformation failed
else
//No disk in removable drive or drive not ready
mInfo->Lines->Add("DRIVE IS NOT READY");
}