Article ID: 202455 - View products that this article applies to.
This article was previously published under Q202455
The Win32 API function GetDiskFreeSpace reports the amount of total and free disk space available on a computer. However, for disks that are larger than 2 gigabytes, the GetDiskFreeSpace function may return misleading values. The new GetDiskFreeSpaceEx Win32 API function returns correct values for all disks, including those that are larger than 2 GB. GetDiskFreeSpaceEx returns values for the total amount of space, the total amount of free space, and the total amount of free space available to the user associated with the calling thread.
This article provides sample code that uses this new function to obtain disk space information for any disk.
GetDiskFreeSpaceEx is supported on Windows NT 4.0 or later and Windows 95 OSR2 or later. It is not supported on Windows CE. Your code can determine whether the GetDiskFreeSpaceEx function is available by checking to see if it is exported by Kernel32. For additional information, see the "Remarks" section for GetDiskFreeSpaceEx in the MSDN Library.
Example of How to Get Disk Space Information by Using GetDiskFreeSpaceEx
MSDN Library; Platform SDK; Base Services; Files and I/O; File I/O; File I/O Reference; File I/O Functions; GetDiskFreeSpace
MSDN Library; Platform SDK; Base Services; Files and I/O; File I/O; File I/O Reference; File I/O Functions; GetDiskFreeSpaceEx
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/153091/EN-US/ )How To Find and View the Amount of Free Disk Space on a Drive
Article ID: 202455 - Last Review: July 13, 2004 - Revision: 2.1
Contact us for more help
Connect with Answer Desk for expert help.