 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
quatermass
Joined: 14 Dec 2005 Posts: 136
|
Posted: Fri Sep 19, 2008 10:39 am Post subject: DriveSpaceFree issue |
|
|
Some of us still have to use floppies and other storage devices that may have less than 1MB of free space on it.
The built-in function DriveSpaceFree rounds down to the nearest MB.
So a storage device like a floppy or a micro storage devices which my company uses may have 900K free on the device and therefore I can still use it.
Can DriveSpaceFree have an extra option added to it to make it not round down, but just return the exact amount?
Cheers.  _________________ Stuart Halliday |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Fri Sep 19, 2008 11:57 am Post subject: |
|
|
You could use GetDiskFreeSpaceEx:
| Code: | Msgbox % GetDiskFreeSpace("A:")
; DriveSpaceFree: 1, Explorer: 1.38 MB free, script: 1.389648 MB
GetDiskFreeSpace( lpDirectoryName )
{
VarSetCapacity( lpFreeBytesAvailable,32 )
DllCall("GetDiskFreeSpaceExA"
, Str, lpDirectoryName, UInt, &lpFreeBytesAvailable, Uint,0, UInt,0 )
Return % Numget( lpFreeBytesAvailable ) / ( 1024*1024 ) . " MB"
} |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
quatermass
Joined: 14 Dec 2005 Posts: 136
|
Posted: Fri Sep 19, 2008 1:04 pm Post subject: |
|
|
| Serenity wrote: | You could use GetDiskFreeSpaceEx:
| Code: | Msgbox % GetDiskFreeSpace("A:")
; DriveSpaceFree: 1, Explorer: 1.38 MB free, script: 1.389648 MB
GetDiskFreeSpace( lpDirectoryName )
{
VarSetCapacity( lpFreeBytesAvailable,32 )
DllCall("GetDiskFreeSpaceExA"
, Str, lpDirectoryName, UInt, &lpFreeBytesAvailable, Uint,0, UInt,0 )
Return % Numget( lpFreeBytesAvailable ) / ( 1024*1024 ) . " MB"
} |
|
Hmm nice solution Serenity.
I seem to be using 3rd party functions more and more these days instead of the built-in one.
I wonder who and when decides if a function needs to be built-in or via a library? I guess in theory very few actually do?
Thanks again for this bit of code.
<added>
Actually I've tried this code now.
It returns the right value for my floppy drive A:
But using it on my D: hard drive which has 8.39GB free it says it has 405.464844 MB free.
I don't think that's right!
 _________________ Stuart Halliday |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Fri Sep 19, 2008 3:16 pm Post subject: |
|
|
This should work:
| Code: | Msgbox % GetDiskFreeSpace("C:")
GetDiskFreeSpace( lpDirectoryName )
{
VarSetCapacity( lpFreeBytesAvailable,32 )
DllCall("GetDiskFreeSpaceExA"
, Str, lpDirectoryName, UInt, &lpFreeBytesAvailable, Uint,0, UInt,0 )
Size := Numget( lpFreeBytesAvailable, 0, "Int64" )
Return Size < 1073741824 ? Size / 1048576 . " MB" : Size / 1073741824 . " GB"
} |
| quatermass wrote: | | I wonder who and when decides if a function needs to be built-in or via a library? I guess in theory very few actually do? |
You could ask for it in the Wish List forum. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|