欧美特黄不卡,涩涩视频在线,成人国产精品一区二区网站,亚洲一区二区三区欧美

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

VB6編程中如何取得硬盤分區信息

VB6編程中如何取得硬盤分區信息

更新時間:2022-05-14 文章作者:未知 信息來源:網絡 閱讀次數:

也許你并不了解硬盤分區信息應該包括些什么,但如果你曾經對硬盤分過區,你或許對此有所了解,在此為各位介紹一個用VB編寫的獲取硬盤分區信息的程序。在這個程序中,它將詳細地告訴你:你的硬盤總容量、分過幾個區、每個區的總容量、及現在剩余的可用容量、硬盤分區表為幾位(即是FAT32還是FAT16),每個分區是幾個字節……怎么樣?夠完整詳細了吧!好的,就讓我們一起來看一下吧:
  首先做準備工作:在FORM1上新建二個LABEL(LABEL1和LABEL2)一個COMMAND1命令按鈕。然后輸入以下代碼:
  Private Declare Function GetDriveType Lib
  kernel32“Alias "GetDriveTypeA(ByVal nDrive As String) As Long
  Private Declare Function GetDiskFreeSpace Lib“kernel32" Alias“GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
  Private Const DRIVE_FIXED = 3
  Private Sub Form_Load() ‘作初始化設置
  COMMAND1.Caption = “測試硬盤"
  Form1.Caption = “測試硬盤程序"
  Label1.WordWrap = True
  Label1.Caption = “"
  Label2.WordWrap = True
  Label2.Caption = “"
  End Sub
  Private Sub COMMAND1_Click()
  Dim DriveNum As Integer
  Dim TempDrive As String
  Dim X As Long
  For DriveNum = 97 To 122 Step 1 ‘檢測從A-Z(盤符)
  TempDrive = GetDriveType(Chr(DriveNum) & “:\")
  Select Case TempDrive ‘如是3則表示是硬盤,測試你有幾個盤
  Case 3: X = GetDiskSpace(Chr(DriveNum)) ‘調用子程序
  End Select
  Next DriveNum
  End Sub
  Public Function GetDiskSpace(DrivePath As String)
  Dim Drive As String
  Dim SectorsPerCluster As Long
  Dim BytesPerSector As Long
  Dim NumberOfFreeClusters As Long
  Dim TotalClusters As Long
  Dim Check As Integer
  Dim DiskSpace
  Dim diskTotal
  Static AllDiskTotal As Long
  Static NUM As Integer
  NUM = NUM + 1 ‘分幾個區的計算
  Drive = Left(Trim(DrivePath), 1) & “:\"
  Check = GetDiskFreeSpace(Drive, SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalClusters)
  If Check <> 0 Then
  DiskSpace = SectorsPerCluster * BytesPerSector * NumberOfFreeClusters
  ‘這是一個分區磁盤剩余空間的計算公式
  DiskSpace = Format$(DiskSpace, “###,###") ‘以規定格式顯示,如732,324,231
  diskTotal = SectorsPerCluster * BytesPerSector * TotalClusters
  ‘這是一個分區磁盤總容量的計算公式
  diskTotal = Format$(diskTotal, “###,###")
  AllDiskTotal = AllDiskTotal + diskTotal ‘整個硬盤的總容量
  Label1.Caption =“你的硬盤總容量為:” & Format$(AllDiskTotal,“###,###") &個字節,即:” & Left(AllDiskTotal, 1) & . & Mid(AllDiskTotal, 2, 1) &“G,一共分了”& NUM &“個區,其中:"
   Label2.Caption = Label2.Caption & UCase(DrivePath) & “盤的整個容量為:" & diskTotal &“個字節" & ",其剩余磁盤空間為:“& DiskSpace & " 個字節,磁盤已FAT“& SectorsPerCluster & ",每個分區為:“& BytesPerSector & "個字節。“& vbCrLf & vbCrLf”
  End If
  End Function
  OK!現在你運行一下,你是否滿意它?
  注:以上程序在中文WINDOWS98,中文VB6.0企業版中調試通過。

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 龙岩市| 四川省| 赤峰市| 房产| 沅江市| 东丰县| 渭南市| 高雄县| 西华县| 龙山县| 上林县| 铁岭市| 建宁县| 体育| 兴义市| 固原市| 犍为县| 西贡区| 石景山区| 龙游县| 蒙自县| 阳信县| 永德县| 尼玛县| 慈利县| 元朗区| 金昌市| 中方县| 宁都县| 奎屯市| 万年县| 克东县| 东乡县| 呼和浩特市| 临泽县| 泰兴市| 渝北区| 九江市| 德安县| 宁乡县| 鹤壁市|