// crt_getdrives.c
// This program retrives and lists out
// all the logical drives that are
// currently mounted on the machine.
#include <windows.h>
#include <direct.h>
#include <stdio.h>
#include <tchar.h>
TCHAR g_szDrvMsg[] = _T("A:\n");
int main(int argc, char* argv[]) {
ULONG uDriveMask = _getdrives();
if (uDriveMask == 0)
{
printf( "_getdrives() failed with failure code: %d\n",
GetLastError());
}
else
{
printf("The following logical drives are being used:\n");
while (uDriveMask) {
if (uDriveMask & 1)
printf(g_szDrvMsg);
++g_szDrvMsg[0];
uDriveMask >>= 1;
}
}
}