/*取得驱动器盘符*/ DWORD dwDrive; INT nDrive;
char dName[4] ; CString Driver; long GB = 1024*1024*1024; //表示级别:GB
/*取得驱动器大小*/ ULARGE_INTEGER Free ; ULARGE_INTEGER Total ; ULARGE_INTEGER TotalFree ;
dwDrive = GetLogicalDrives();
for ( nDrive = 0 ; nDrive < 26 ; nDrive++ ){ if ( dwDrive & (1 << nDrive) ){ sprintf(dName,"%c:\\",(nDrive + 'A')); Driver = CString(dName);
if(GetDiskFreeSpaceEx((LPCWSTR)Driver,&Free,&Total,&TotalFree)){ printf("%s:\\ 剩余:%3I64u GB 容量:%I64u GB \n",Driver,Free.QuadPart/GB,Total.QuadPart/GB); } } } |