monoceres Posted June 26, 2008 Share Posted June 26, 2008 (edited) Hi! Needed this for a project of mine and I thought that someone else might need it. UDF: ; #FUNCTION#;=============================================================================== ; ; Name...........: _DriveGetClusterSize ; Description ...: Returns the cluster size of a drive ; Syntax.........: _DriveGetClusterSize([$sDrive=@HomeDrive]) ; Parameters ....: ; Return values .: Success - Cluster size in bytes ; .; Failure - -1 and @error=1 ; Author ........: Andreas Karlsson (monoceres) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; No ; ;;========================================================================================== Func _DriveGetClusterSize($sDrive = @HomeDrive) If StringRight($sDrive,1)<>'\' Then $sDrive&='\' Local $iClusterSize, $vNULL, $aArray $aArray = DllCall("Kernel32.dll", "int", "GetDiskFreeSpace", "str", $sDrive, "dword*", $vNULL, "dword*", $vNULL, "dword*", $vNULL, "dword*", $vNULL) If IsArray($aArray) Then $iClusterSize = $aArray[2] * $aArray[3] Return SetError(0,0,$iClusterSize) EndIf Return SetError(1,0,-1) EndFunc;==>_GetClusterSize Example: $file=FileOpenDialog("Select file","","All files (*.*)") $size=FileGetSize($file) $clustersize=_DriveGetClusterSize(StringLeft($file,3)) $sizeondisc=Ceiling($size/$clustersize)*$clustersize MsgBox(0,"Info","Filename: "&$file&@CRLF&"Filesize: "&$size&" bytes"&@CRLF&"Size on disc: "&$sizeondisc&" bytes"&@CRLF&"Wasted: "&$sizeondisc-$size&" bytes") Edited June 26, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
gseller Posted June 26, 2008 Share Posted June 26, 2008 Nice funtion, thanks for sharing.. Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted June 26, 2008 Share Posted June 26, 2008 Nice Job!Oh.. I think you forgot something $aArray = DllCall("Kernel32.dll", "int", "GetDiskFreeSpace", "str", $sDrive, "dword*", $vNULL, "dword*", $vNULL, "dword*", $vNULL, "dword*", $vNULL) Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
Andreik Posted June 26, 2008 Share Posted June 26, 2008 Thanks monoceres! Link to comment Share on other sites More sharing options...
monoceres Posted June 26, 2008 Author Share Posted June 26, 2008 Oh.. I think you forgot something Thanks for noticing Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
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