engjcowi Posted July 5, 2010 Posted July 5, 2010 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
Makaule Posted July 5, 2010 Posted July 5, 2010 (edited) 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 July 5, 2010 by Makaule
engjcowi Posted July 5, 2010 Author Posted July 5, 2010 Thanks Very Much everyday is a learning day and ive learnt today. jamie Drunken Frat-Boy Monkey Garbage
Spiff59 Posted July 6, 2010 Posted July 6, 2010 (edited) 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 July 6, 2010 by Spiff59
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now