[python-win32] GetDiskFreeSpaceEx

Stormy stormy at stormweyr.dk
Tue Jul 13 16:32:53 CEST 2010

GetDiskFreeSpaceEx() has two names (as does most windows functions
that use strings), the Ansi version and the Unicode version, and you
need to use the real name for the function you wish to use, in this
case it is GetDiskFreeSpaceExA and GetDiskFreeSpaceExW.

As for calling this function:

from ctypes import c_ulong, byref, windll

freeBytesAvailable = c_ulong()
totalNumberOfBytes = c_ulong()
totalNumberOfFreeBytes = c_ulong()

# Ansi version:
windll.kernel32.GetDiskFreeSpaceExA('c:\\', byref(freeBytesAvailable),
byref(totalNumberOfBytes), byref(totalNumberOfFreeBytes))

# Unicode version:
byref(freeBytesAvailable), byref(totalNumberOfBytes),

print totalNumberOfFreeBytes.value

The only difference in parameters is the type of string passed.

On Tue, Jul 13, 2010 at 2:50 PM, Vittorio Zuccala'
<vittorio.zuccala at gmail.com> wrote:
> Hi all,
> i'm new in this mail-list and in python's programming.
> Sorry for my bad english :-)
> I'm searching information about getting free disk space on win32 systems...
> I found example about win32 programming in python in Tim's site at this link
> http://timgolden.me.uk/python/win32_how_do_i/lock_my_workstation.html and
> information about Free Disk Space at this link:
> http://msdn.microsoft.com/en-us/library/aa364937%28VS.85%29.aspx
> So... I tried to make 1+1 with this code but it doesn't work :-(
> import ctypes
> ctypes.windll.kernel32.GetDiskFreeSpaceEx()
> May you help me to understand?
> PS: i wrote code into linux. I'm just new in win32 system programming.
> Many thanks,
> Vittorio
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32

More information about the python-win32 mailing list