Well if you read the documentation for GetDiskFreeSpace(), the following comment will make you want to use GetDiskFreeSpaceEx():

The GetDiskFreeSpace function returns incorrect values for volumes that are larger than 2 gigabytes. The function caps the values stored into *lpNumberOfFreeClusters and *lpTotalNumberOfClusters so as to never report volume sizes that are greater than 2 gigabytes.
Even on volumes that are smaller than 2 gigabytes, the values stored into *lpSectorsPerCluster, *lpNumberOfFreeClusters, and *lpTotalNumberOfClusters values may be incorrect. That is because the operating system manipulates the values so that computations with them yield the correct volume size.

However, if you read the documentation for GetDiskFreeSpaceEx(), you will notice there is a small problem when targeting Windows95: You cannot guarantee that GetDiskFreeSpaceEx() is available. (Prior to OSR2, you only get GetDiskFreeSpace().)

This means if you need to target Windows95, you need to determine on the fly whether GetDiskFreeSpaceEx() is available or not. If it is, great...if not, you have to use GetDiskFreeSpace().

One way of doing this on the fly, is to load the Kernel32 DLL and determine whether GetDiskFreeSpaceEx() exists or not. If we get a pointer to the function, we can call it...if not, we know we have to use GetDiskFreeSpace():

how to get the total hard disk space

hi there,
i need some sample code for how to get the total hard disk space on an windows NT 4.0.
i tried getfreediskspaceEx() but got some error in kernel32.lib that was access violation error
can u please send me a sample code how to get total hard disk space
thanx
sujeet

Re-make this function (if you have error C2197 code ...)

// We need to determine whether GetDiskFreeSpaceEx is available by calling LoadLibrary
// or LoadLibraryEx, to load Kernel32.DLL, and then calling the GetProcAddress to
// obtain an address for GetDiskFreeSpaceEx. If GetProcAddress fails, or if
// GetDiskFreeSpaceEx fails with the ERROR_CALL_NOT_IMPLEMENTED code, we use the
// GetDiskFreeSpace function instead.

PB with V5.0 ??

Hello
I use GetDiscFreeSpace in my own Project
Visual C++ 5.0 Wint NT 4.0 and i have some errors :
error C2197: 'int (__stdcall *)(void)' : too many actual parameters
a the line if((*lpfnDLLProc)(lpszPath, &nTotalAvailable, &nTotalBytes, &nTotalFreeBytes))

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.

Thanks for your registration, follow us on our social networks to keep up-to-date