G
Guest
Hi,
I have a big problem with a Visual C++ 6.0 function that retrives the
logical drives and types in the local system.
This function works perfectly on Windows 98, NT, 2000, XP and 2003, but I
have tested it on Windows Vista and it doesn't retrieve remote network
drives. It must retrieve a string with the drive letters and a string with
the drive types (2=removable drive, 3=hard drive, 4=remote drive, 5=CD-ROM
drive, 6=RAM drive)
I always run this function using a Windows user in the Administrators group,
but it still fails in Windows Vista.
Do you know how to configure Windows Vista in order to get the local network
drives?
This is my code with debug message boxes:
void GetLocalDrives(CString &strDrives, CString &strTypes)
{
DWORD unitmask;
char units[27];
char types[27];
int i, n;
char unit[4];
UINT unittype;
char szMsg[80];
unitmask = GetLogicalDrives();
n = 0;
for (i = 0; i < 26; i++)
{
if (unitmask & 0x1)
{
sprintf(unit, "%c:\\", 'A' + i);
units[n] = *unit;
unittype = GetDriveType(unit);
types[n++] = '0' + unittype;
switch (unittype)
{
case DRIVE_UNKNOWN:
sprintf(szMsg, "Drive %s of unknown type", unit);
break;
case DRIVE_NO_ROOT_DIR:
sprintf(szMsg, "Drive %s is invalid", unit);
break;
case DRIVE_REMOVABLE:
sprintf(szMsg, "Drive %s is a removable drive", unit);
break;
case DRIVE_FIXED:
sprintf(szMsg, "Drive %s is a hard disk", unit);
break;
case DRIVE_REMOTE:
sprintf(szMsg, "Drive %s is a network drive", unit);
break;
case DRIVE_CDROM:
sprintf(szMsg, "Drive %s is a CD-ROM drive", unit);
break;
case DRIVE_RAMDISK:
sprintf(szMsg, "Drive %s is a RAM disk", unit);
break;
default:
sprintf(szMsg, "Drive %s has an unknown %u drive type", unit,
unittype);
}
AfxMessageBox(szMsg);
}
unitmask = unitmask >> 1;
}
units[n] = '\0';
types[n] = '\0';
sprintf(szMsg, "Local drives:\t%s\nTypes:\t%s\n", units, types);
AfxMessageBox(szMsg);
strDrives = units;
strTypes = types;
}
Thanks,
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:[email protected]
I have a big problem with a Visual C++ 6.0 function that retrives the
logical drives and types in the local system.
This function works perfectly on Windows 98, NT, 2000, XP and 2003, but I
have tested it on Windows Vista and it doesn't retrieve remote network
drives. It must retrieve a string with the drive letters and a string with
the drive types (2=removable drive, 3=hard drive, 4=remote drive, 5=CD-ROM
drive, 6=RAM drive)
I always run this function using a Windows user in the Administrators group,
but it still fails in Windows Vista.
Do you know how to configure Windows Vista in order to get the local network
drives?
This is my code with debug message boxes:
void GetLocalDrives(CString &strDrives, CString &strTypes)
{
DWORD unitmask;
char units[27];
char types[27];
int i, n;
char unit[4];
UINT unittype;
char szMsg[80];
unitmask = GetLogicalDrives();
n = 0;
for (i = 0; i < 26; i++)
{
if (unitmask & 0x1)
{
sprintf(unit, "%c:\\", 'A' + i);
units[n] = *unit;
unittype = GetDriveType(unit);
types[n++] = '0' + unittype;
switch (unittype)
{
case DRIVE_UNKNOWN:
sprintf(szMsg, "Drive %s of unknown type", unit);
break;
case DRIVE_NO_ROOT_DIR:
sprintf(szMsg, "Drive %s is invalid", unit);
break;
case DRIVE_REMOVABLE:
sprintf(szMsg, "Drive %s is a removable drive", unit);
break;
case DRIVE_FIXED:
sprintf(szMsg, "Drive %s is a hard disk", unit);
break;
case DRIVE_REMOTE:
sprintf(szMsg, "Drive %s is a network drive", unit);
break;
case DRIVE_CDROM:
sprintf(szMsg, "Drive %s is a CD-ROM drive", unit);
break;
case DRIVE_RAMDISK:
sprintf(szMsg, "Drive %s is a RAM disk", unit);
break;
default:
sprintf(szMsg, "Drive %s has an unknown %u drive type", unit,
unittype);
}
AfxMessageBox(szMsg);
}
unitmask = unitmask >> 1;
}
units[n] = '\0';
types[n] = '\0';
sprintf(szMsg, "Local drives:\t%s\nTypes:\t%s\n", units, types);
AfxMessageBox(szMsg);
strDrives = units;
strTypes = types;
}
Thanks,
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:[email protected]