I'm trying to list through all the logical drives in the computer using this code:
for (int i = 0; i < 26; i++)
{
if ((GetLogicalDrives() & ( 1 << i )))
{
CHAR driveName[MAX_PATH] = {TEXT('A') + i, TEXT(':'), TEXT('\\'), TEXT('\0')};
std::cout << driveName << std::endl;
}
}
It works, but when I try to access the A:\ drive, which in my computer stands for the floppy disk, it displays me an error saying "Device not ready".
try
{
std::cout << GetFileAttributes(driveName) << std::endl;
}
catch (const std::string& ex)
{
}
Is there any way to check if a logical drive is ready before doing something with it?
Thanks.

New Topic/Question
Reply



MultiQuote







|