VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Gets the drive memory, same as below. Just correcting errors

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)

Gets the drive memory, same as below. Just correcting errors

Rate Gets the drive memory, same as below. Just correcting errors



Dim free, tob, tofb As Currency ' Sorry forget to add this to the other script
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

Gets the drive memory, same as below. Just correcting errors Comments

No comments have been posted about Gets the drive memory, same as below. Just correcting errors. Why not be the first to post a comment about Gets the drive memory, same as below. Just correcting errors.

Post your comment

Subject:
Message:
0/1000 characters