程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 取得Disk Free Space與Total Space

取得Disk Free Space與Total Space

編輯:VB綜合教程

  

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
'Path = "c:\" 指定Volume 代號, 如: c:\ d:\ e:\
Public Function GetFreeSpace(Byval Path as String) as Long
Dim aa As Long
Dim Path As String
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
Path = "c:\" '指定Volume 代號, 如: c:\ d:\ e:\
aa = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
GetFreeSpace = SecPerClust * BytePerSec * FreeClust
End Function
'Path = "c:\" 指定Volume 代號, 如: c:\ d:\ e:\
Public Function GetTotalSpace(Byval Path as String) as Long
Dim aa As Long
Dim Path As String
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
aa = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
GetTotalSpace = SecPerClust * BytePerSec * totClust
End Function

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved