VB and VBA Users Source Code: Determine the free space on a drive
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Determine the free space on a drive
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, December 13, 2000
Hits:
868
Category:
Windows API
Article:
To determine the free space on a drive use the following routine: Option Explicit Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long 'Purpose : Determine the amount of free disk space on a drive (in Bytes) 'Inputs : sDriveLetter The drive letter eg. "C" 'Outputs : The free space in Bytes 'Author : Andrew Baker 'Date : 13/12/2000 10:33 'Notes : 'Revisions : 'Assumptions : Function DriveFreeSpace(sDriveLetter As String) As Double Dim lRet As Long, cBytesFree As Currency, cTotalBytes As Currency, cTotalBytesFree As Currency On Error Resume Next If GetDiskFreeSpaceEx(Left$(sDriveLetter, 1) & ":\", cBytesFree, cTotalBytes, cTotalBytesFree) <> 0 Then DriveFreeSpace = (cTotalBytes - cBytesFree) * 10000 End If On Error GoTo 0 End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder