procedure Getdiskinf();<br>var<br>Name: CHAR;<br>Sector, Byte, Cluster, Free: Dword;<br>begin<br> for Name := 'C' to 'Z' do //循环检测C~Z<br> begin<br> drvname := Name + ':';<br> CDtype := GetDriveType(PCHAR(@drvname[1])); //获得磁盘类型<br> case cdtype of<br> DRIVE_REMOVABLE://移动驱动器<br> begin<br> GetDiskFreeSpace(PChar(drvname), LPDWORD(@sector)^, LPDWORD(@byte)^, LPDWORD(@free)^, LPDWORD(@cluster)^); //获得返回参数<br> totalspace := cluster * byte * sector div 1024 div 1024; //计算总容量<br> freespace := free * byte * sector div 1024 div 1024; //计算可用空间<br> end;<br> DRIVE_RAMDISK://RAMDISK<br> begin<br> GetDiskFreeSpace(PChar(drvname), LPDWORD(@sector)^, LPDWORD(@byte)^, LPDWORD(@free)^, LPDWORD(@cluster)^); //获得返回参数<br> totalspace := cluster * byte * sector div 1024 div 1024; //计算总容量<br> freespace := free * byte * sector div 1024 div 1024; //计算可用空间<br> end;<br>end;