====== List all available drives ======
This code snippet is originally from the former WinAPI site www.winapi.net
Sometimes you need to know about all logical drives. The WinAPI gives us for that the function ''GetLogicalDrives()''. It returns a bit mask which has to be analysed. Here is an example how:
#include
#include
#include
#include
#ifndef BITSPERBYTE
#define BITSPERBYTE 8
#endif
#define IS_BIT(val, bit) ((val) & (1 << (bit)))
int _tmain(void)
{
DWORD dwLogicalDrives, x;
TCHAR szRoot[32];
dwLogicalDrives = GetLogicalDrives();
for(x = 0; x < (sizeof(dwLogicalDrives) * BITSPERBYTE); x++)
{
if(IS_BIT(dwLogicalDrives, x))
{
PathBuildRoot(szRoot, x);
_tprintf(TEXT("%s - DriveType: 0x%08X\n"), szRoot, GetDriveType(szRoot));
}
}
return(0);
}