Jump to content
Sign in to follow this  

Disk space used on Volume?

Recommended Posts

There is the API _WinAPI_GetDiskFreeSpaceEx() to get the free space remaining on a volume.  But I have not found any API to get either the capacity of a volume or the used space on a volume.  It seems like it should be a no brainer.  But I suspect it will be one of those WMI deals for some unknown reason.


Anyone have a non WMI solution?


Share this post

Link to post
Share on other sites

Try this:

#include <WinAPIMisc.au3>

ConsoleWrite(_WinAPI_GetDiskFreeSpace("C") & @CRLF)

Func _WinAPI_GetDiskFreeSpace($sDrive, $bAutoConvert = False)
    Local $aRes = DllCall("kernel32.dll", "uint", "GetDiskFreeSpace", "str", StringLeft($sDrive, 1) & ":\", "dword*", NULL, "dword*", NULL, "dword*", NULL, "dword*", NULL)
    If @error Or Not $aRes[0] Then Return SetError(1, 0, 0)
    Return $bAutoConvert ? _WinAPI_StrFormatByteSize($aRes[2] * $aRes[4] * $aRes[3]) : $aRes[2] * $aRes[4] * $aRes[3]



#include <WinAPIFiles.au3>
_WinAPI_GetDiskFreeSpaceEx ( $sDrive )


Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
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
Sign in to follow this  

  • Create New...