void test2()
{
DWORD dwLen = GetLogicalDriveStrings(0, NULL);
char * pszDriver = new char[dwLen];
GetLogicalDriveStrings(dwLen, pszDriver);
vector<string> v;
while (*pszDriver != '\0')
{
cout << pszDriver << " ---- " << endl;
v.push_back(pszDriver);
pszDriver += strlen(pszDriver) + 1;
}
int DType;
int si = 0;
BOOL fResult;
unsigned _int64 i64FreeBytesToCaller;
unsigned _int64 i64TotalBytes;
unsigned _int64 i64FreeBytes;
for (int i = 0; i < dwLen / 4; ++i)
{
DType = GetDriveType(v[i].c_str());
if (DType == DRIVE_FIXED)
{
cout << " ";
}
else if (DType == DRIVE_CDROM)
{
cout << " ";
}
else if (DType == DRIVE_REMOVABLE)
{
cout << " ";
}
else if (DType == DRIVE_REMOTE)
{
cout << " ";
}
else if (DType == DRIVE_RAMDISK)
{
cout << " RAM ";
}
else if (DType == DRIVE_UNKNOWN)
{
cout << " ";
}
fResult = GetDiskFreeSpaceEx(
v[i].c_str(),
(PULARGE_INTEGER)&i64FreeBytesToCaller,
(PULARGE_INTEGER)&i64TotalBytes,
(PULARGE_INTEGER)&i64FreeBytes);
if (fResult)
{
cout << " totalspace:" << (float)i64TotalBytes / 1024 / 1024 << " MB";
cout << " freespace:" << (float)i64FreeBytesToCaller / 1024 / 1024 << " MB";
}
else
{
cout << " ";
}
cout << endl;
si += 4;
}
}