-
Part of my app needs to calculate stuff about the Users hard disk(s) which would be done using the GetDiskFreeSpace API. The problem is that this will not work on Drives over 2GB in size, or FAT32 Drives. The recommended Microsoft solution is to use the GetDiskFreeSpaceEx API. My questions are this....
1) Does the GetDiskFreeSpaceEx API use the same parameters as GetDiskFreeSpace?
2) Will GetDiskFreeSpaceEx work with FAT16, sub 2GB drives, removing the need to use GetDiskFreeSpace at all?
3) If not, Microsoft also recommend that you use the GetVersionEx API to determine the users Windows version. How can I distinguish between different versions of Win 95 when using this?
Thanks in Advance!!
-
Here's how you can use GetDiskFreeSpaceEx
Code:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Function GetFreeSpace(p_strDrive As String) As String
Dim curTotalBytes As Currency
Dim curFreeBytesToCaller As Currency
Dim curTotalFreeBytes As Currency
Call GetDiskFreeSpaceEx(strDrive, curFreeBytesToCaller, curTotalBytes, curTotalFreeBytes)
GetFreeSpace = Format$(curTotalFreeBytes * 10000, "###,###,###,##0")
End Function
Example:
MsgBox "Free space on drive C: is: " & GetFreeSpace("C:")
This will get size of hard drives bigger then 2GB.
Regards,
-