|
|
|
Click here to copy the following block | Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal _ lpLibFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _ ByVal lpProcName As String) As Long Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias _ "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, _ lpFreeBytesAvailableToCaller As Any, lpTotalNumberOfBytes As Any, _ lpTotalNumberOfFreeBytes As Any) As Long Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias _ "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _ lpSectorsPerCluster As Long, lpBytesPerSector As Long, _ lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Sub GetDiskFreeBytes(driveName As String, FreeBytesAvailableToCaller As _ Currency, TotalBytesAvailableToCaller As Currency, _ TotalFreeBytes As Currency)
Dim hModule As Long, procAddr As Long, res As Long hModule = LoadLibrary("kernel32.Dll") If hModule Then procAddr = GetProcAddress(hModule, "GetDiskFreeSpaceExA") If procAddr Then res = GetDiskFreeSpaceEx(driveName, FreeBytesAvailableToCaller, _ TotalBytesAvailableToCaller, TotalFreeBytes) FreeLibrary hModule If res = 0 Then Err.Raise 5, , Err.LastDllError Else FreeBytesAvailableToCaller = FreeBytesAvailableToCaller * 10000 TotalBytesAvailableToCaller = TotalBytesAvailableToCaller * _ 10000 TotalFreeBytes = TotalFreeBytes * 10000 Exit Sub End If End If FreeLibrary hModule End If Dim lpSectorsPerCluster As Long Dim lpBytesPerSector As Long Dim lpNumberOfFreeClusters As Long Dim lpTotalNumberOfClusters As Long res = GetDiskFreeSpace(driveName, lpSectorsPerCluster, lpBytesPerSector, _ lpNumberOfFreeClusters, lpTotalNumberOfClusters) If res = 0 Then Err.Raise 5, , Err.LastDllError Else FreeBytesAvailableToCaller = lpNumberOfFreeClusters * _ lpSectorsPerCluster * lpBytesPerSector TotalBytesAvailableToCaller = lpTotalNumberOfClusters * _ lpSectorsPerCluster * lpBytesPerSector TotalFreeBytes = FreeBytesAvailableToCaller End If End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|