VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Find free disk space on a computer

by Anonymous (267 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 24th November 1998
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Find free disk space on a computer

API Declarations



Public Type DiskInformation
lpSectorsPerCluster As Long
lpBytesPerSector As Long
lpNumberOfFreeClusters As Long
lpTotalNumberOfClusters As Long
End Type

Rate Find free disk space on a computer



Dim lAnswer As Long
Dim lpRootPathName As String
Dim lpSectorsPerCluster As Long
Dim lpBytesPerSector As Long
Dim lpNumberOfFreeClusters As Long
Dim lpTotalNumberOfClusters As Long
Dim lBytesPerCluster As Long
Dim lNumFreeBytes As Double
Dim sString As String

lpRootPathName = "c:\"
lAnswer = GetDiskFreeSpace(lpRootPathName, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters)
lBytesPerCluster = lpSectorsPerCluster * lpBytesPerSector
lNumFreeBytes = lBytesPerCluster * lpNumberOfFreeClusters
sString = "Number of Free Bytes : " & lNumFreeBytes & vbCr & vbLf
sString = sString & "Number of Free Kilobytes: " & (lNumFreeBytes / 1024) & "K" & vbCr & vbLf
sString = sString & "Number of Free Megabytes: " & Format(((lNumFreeBytes / 1024) / 1024), "0.00") & "MB"

MsgBox sString


Download this snippet    Add to My Saved Code

Find free disk space on a computer Comments

No comments have been posted about Find free disk space on a computer. Why not be the first to post a comment about Find free disk space on a computer.

Post your comment

Subject:
Message:
0/1000 characters