用GetVolumnInformation函数,和读取硬盘的一样.下面是一个DEmo.<br>Demo中的label就是.<br><br>function TSysinfo.GetDiskInfo(strDrive : string) : boolean;<br>var<br> lpLabel : pChar;<br> LabelSize : cardinal;<br> SerialNum : cardinal;<br> MaxLength : cardinal;<br> lpFileName : pChar;<br> Filesize : cardinal;<br> FileFlag : cardinal;<br><br> FreeSpace,TotalSpace : int64;<br> str : string;<br>begin<br> result := true;<br> LabelSize := 255;<br> FileSize := 255;<br> GetMem(lpLabel,LabelSize);<br> GetMem(lpFileName,Filesize);<br> try<br> if GetVolumeInformation(PChar(strDrive),lpLabel,LabelSize,@SerialNum,<br> MaxLength,FileFlag,lpFileName,FileSize) then<br> begin<br> DiskInfo.DiskName := strDrive;<br> DiskInfo.DiskLabel := lpLabel;<br> DiskInfo.DiskFormat := lpFileName;<br> str := IntToHex(SerialNum,8);<br> DiskInfo.DiskSerialNum := Copy(str,1,4)+':'+Copy(str,5,4);<br> end<br> else<br> result := False;<br><br> case GetDriveType(PChar(DiskInfo.DiskName)) of<br> DRIVE_UNKNOWN : DiskInfo.DiskType := '未知驱动器';<br> DRIVE_NO_ROOT_DIR : DiskInfo.DiskType := '不是驱动器';<br> DRIVE_REMOVABLE : DiskInfo.DiskType := '软驱';<br> DRIVE_FIXED : DiskInfo.DiskType := '本地硬盘';<br> DRIVE_REMOTE : DiskInfo.DiskType := '网络硬盘';<br> DRIVE_CDROM : DiskInfo.DiskType := '光驱';<br> DRIVE_RAMDISK : DiskInfo.DiskType := '虚拟硬盘';<br> else DiskInfo.DiskType := '未知驱动器';<br> end;<br><br> if GetDiskFreeSpaceEx(PChar(DiskInfo.DiskName),FreeSpace,TotalSpace,nil) then<br> begin<br> DiskInfo.DiskTotalSpace := CaculateByte(TotalSpace);<br> DiskInfo.DiskFreeSpace := CaculateByte(FreeSpace);<br> DiskInfo.DiskUsageSpace := Trunc((TotalSpace - FreeSpace) / TotalSpace * 100);<br> end<br> else<br> result := false;<br> finally<br> FreeMem(lpLabel);<br> FreeMem(lpFileName);<br> end;<br>end;<br>