Jump to content

Drive space


Recommended Posts

hi guys

Ive been compiling a system info tool and the DriveSpaceTotal(@HomeDrive) and MemGetStats() work and show me the mb of what i have on my computer. ive tried a few things to get it to show 1 TB or 320 GB or round off to what it actually is instead of 32543215 or some other series of numbers lol. Same problem with the ram. does anyone have any code to do this.

Sorry if ive not made full sense im having a brain freeze today lol

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

just divide number which you got from 1024^N, where N depends from the unit which you want get. For example: 32543215[KB]= 32543215 / (1024^1) [MB] = 32543215 / (1024^2) [GB] and etc.

If you want to round result, then just use Round() function.

$var = DriveSpaceTotal("C:\")
MsgBox(0, "Results", _
"===== Normal Results =====" & @CRLF & _
"Total Space on C: " & $var & " MB" & @CRLF & _
"Total Space on C: " & $var/(1024^1) & " GB" & @CRLF & _
"Total Space on C: " & $var/(1024^2) & " TB" & @CRLF & _
"===== Rounded Results =====" & @CRLF & _
"Total Space on C: " & Round($var, 1) & " MB" & @CRLF & _
"Total Space on C: " & Round($var/(1024^1), 1) & " GB" & @CRLF & _
"Total Space on C: " & Round($var/(1024^2), 1) & " TB" & @CRLF)
Edited by Makaule
Link to comment
Share on other sites

I've used the little function below to display drive free space, in a nicely formatted manner:

$filesize = 2048204812
MsgBox(1,"",_ShowBytes($filesize))

;------------------------------------------------------------------------------
Func _ShowBytes($bytes)
    Local $x, $bytes_suffix[6] = [" B"," KB"," MB"," GB"," TB"," PB"]
    While $bytes > 1023
        $x += 1
        $bytes /= 1024
    WEnd
    Return Round($bytes, 2) & $bytes_suffix[$x]
EndFunc

Edit: Added 'petabytes', now it's ready for Y3K...

Edited by Spiff59
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...