2011年6月30日 星期四

[轉貼] VB6.0 如何知道遠端電腦的剩餘磁碟空間

來源:http://www.programmer-club.com.tw/ShowSameTitleN/vb/32456.html

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

Public Function GetFreeHDSpace(ByVal Path As String) As Variant
Dim Status As Long
Dim dbV As Double
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
Status = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
dbV = SecPerClust * BytePerSec
dbV = dbV * FreeClust
GetFreeHDSpace= dbV
End Function

Private Sub Command1_Click()
MsgBox GetFreeSpace("\\x.x.x.x\c$")
End Sub

沒有留言:

張貼留言