How do you determine if a file is on a removable drive or in the local drive in vc++?
+3
A:
Call the GetDriveType API.
Edit:
UINT driveType = GetDriveType(lpFileName);
if (driveType == DRIVE_FIXED)
{
/* fixed drive */
}
else if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
{
/* removable drive */
}
else
{
/* other case e.g. network, RAM disk */
}
itowlson
2009-10-26 01:16:45
can you give me an example code snippet?
blue
2009-10-26 01:21:59
`UINT driveType = GetDriveType(lpFileName); if (driveType == DRIVE_FIXED) { /* fixed drive */ } else if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) { /* removable drive */ } else { /* other case e.g. network, RAM disk */ }`
itowlson
2009-10-26 01:30:46