VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get f

by Craig Phillips (5 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 24th December 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get free, used and capacity memory.

Rate Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get f




Private Sub Timer1_Timer()
Dim freec, tob, tofb As Currency
a = GetDiskFreeSpaceEx("C:\", freec, tob, tofb)
' Get the capacity of C drive
totm = (tob * 10000) ' Times by 10000
If totm / 1024 < 1 Then ' Getting the units
unit = "Bytes"
End If
If totm / 1024 / 1024 < 1 Then
totm = totm / 1024
unit = "KB"
End If
If totm / 1024 / 1024 / 1024 < 1 Then
totm = totm / 1024 / 1024
unit = "MB"
Else
totm = totm / 1024 / 1024 / 1024
unit = "Gb"
End If
totm2 = InStr(totm, ".") ' Getting the decimal place to shorten the value
totm3 = Mid(totm, 1, totm2 + 2)
' Get the freespace of the C drive
tofbm = tofb * 10000 ' Times by 10000
If tofbm / 1024 < 1 Then ' Getting the units
unit2 = "Bytes"
End If
If tofbm / 1024 / 1024 < 1 Then
tofbm = tofbm / 1024
unit2 = "KB"
End If
If tofbm / 1024 / 1024 / 1024 < 1 Then
tofbm = tofbm / 1024 / 1024
unit2 = "MB"
Else
tofbm = tofbm / 1024 / 1024 / 1024
unit2 = "Gb"
End If
tofbm2 = InStr(tofbm, ".") ' Getting the decimal place to shorten the value
tofbm3 = Mid(tofbm, 1, tofbm2 + 2)
Label1.Caption = "Used Space: " & totm3 - tofbm3 & "" & vbCrLf & "Free Space: " & tofbm3 & "" & vbCrLf & "Drive Capacity: " & totm3
End Sub

Download this snippet    Add to My Saved Code

Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get f Comments

No comments have been posted about Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get f. Why not be the first to post a comment about Retrieves the complete disk memory for the C drive. You can change the drive. You are able to get f.

Post your comment

Subject:
Message:
0/1000 characters