Jump to content

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?

 

Link to comment
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]
EndFunc

 

Or 

#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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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...