'GetLogicalDrives and bit position 23
As far as I understand, if I would like to check for X:\ drive, It would be bit 23 if using the GetLogicalDrives function; so, I am trying to test that, but it turns to 0 if I set the bitmask to >>=23.
This is my code:
DWORD drives;
drives = GetLogicalDrives();
drives >>= 23;
if (drives == 0)
{
wprintf(L"Error: %lu\n", GetLastError());
}
else if (drives & 1)
{
wprintf(L"Drive is mounted\n");
}
else
{
wprintf(L"Drive is not mounted\n");
}
Now, if I set drives, for example, to 17, which, I believe, would refers to letter R, It will be tested in the first else and, if it is not mounted, will go to the second; so it will show Drive is not mounted. Same if I set drives>>=1, which refers to B, I think.
It will get 0 only from 19 (letter T) to 25 (letter Z), if they are not mounted.
What am I doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
