I need to show the user a list of drives to select from, is there an easy way to do this in MFC, or if not with the api?
TIA
Jim Hewitt, Liberty Tax Service
Printable View
I need to show the user a list of drives to select from, is there an easy way to do this in MFC, or if not with the api?
TIA
Jim Hewitt, Liberty Tax Service
There's a function called GetLogicalDrives() that will return to you a DWORD containing a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.
To determine which drives are present, you can do something like this:
DWORD dwRes = GetLogicalDrives();
if (0 != dwRes)
{
while (dwRes)
{
// Check if the bit is a "1" or a "0"
if (dwRes & 1)
MessageBox("Found a drive!");
// Shift the value over by one
dwRes >>= 1;
}
}
Hope this helps!! Happy coding,
=================================================
Valerie L. Bradley
Software Engineer
Intel Corporation
* All opinions expressed are mine and not those of my employer.