I would like to know what the snippet of code does..
Drive[0] = 'A';
Drive[1] = ':';
Drive[2] = '\\';
Drive[3] = 0;
DriveMask = GetLogicalDrives();
for( anIndex = 0; anIndex < 26;
anIndex++ )
{
if( DriveMask & 1 )
{
Drive[0] = 'A' + anIndex;
DriveMask >>= 1;
}
}
Please let me know your answer.
Thank you for your time to read my post.
It’s enumerating all the possible attached drives between A:\ and Z:\ and checking to see whether they’re removable (eg CD, floppy).
It loops 26 times, and each time
causes the bitmask to be shifted right by 1 bit, so that each logical drive can be tested for via the
in succession.
GetDriveType() requires a drive path, so the label is constructed by adding the loop count to the letter A (so A, B, C, D, …, Z) and leaving the previously-initialized :\ part in-place.