|
VB中获取逻辑磁盘的信息(2) PercentFree As Long, Dl As Long Dim DrvName As String List1.Clear Volume = String(256, 0) SysName = String(256, 0) DrvName = Left(Drive1.Drive, 2) & "\" Res = GetVolumeInformation(DrvName, Volume, 255, SerialNum, _ ComponentLength, SysFlags, SysName, 255) If Res = 0 Then List1.AddItem "不能得到磁盘信息" Else List1.AddItem "卷标: " & Trim(Volume) List1.AddItem "序列号: " & SerialNum List1.AddItem "成分长度: " & ComponentLength List1.AddItem "文件系统: " & Trim(SysName) Dl = GetDiskFreeSpace(DrvName, SectorsPerCluster, BytesPerSector, NumberOfFreeClustors, TotalNumberOfClustors) List1.AddItem "每簇中扇区数: " & Format(SectorsPerCluster, "#,0") List1.AddItem "每扇区中字节数: " & Format(BytesPerSector, "#,0") List1.AddItem "总簇数: " & Format(TotalNumberOfClustors, "#,0") List1.AddItem "剩余簇数: " & Format(NumberOfFreeClustors, "#,0") TotalBytes = TotalNumberOfClustors * SectorsPerCluster * BytesPerSector List1.AddItem "总字节数: " & Format(TotalBytes, "#,0") FreeBytes = NumberOfFreeClustors * SectorsPerCluster * BytesPerSector List1.AddItem "剩余字节数: " & Format(FreeBytes, "#,0") If SysFlags And FS_CASE_IS_PRESERVED Then List1.AddItem "文件名的大小写记录于文件系统" End If
|