Hi, I am trying to simply get the free disk space of Drive C, but it seems no matter what method I use I either Get an overflow, or I get 0k. Here's basically what I have:
-------------------Begin Code-------------------------
Private Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Function FreeDiskSpace(DriveLetter As String)
Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim FreeClusters As Long
Dim NumberOfClusters As Long
Dim ret As Long
ret = GetDiskFreeSpace(DriveLetter & ":\", SectorsPerCluster, BytesPerSector, FreeClusters, NumberOfClusters)
FreeDiskSpace = BytesPerSector * SectorsPerCluster * FreeClusters
End Function
Private Sub Command1_Click()
MsgBox FreeDiskSpace("C") \ 1024 & " Kb Free Space in Drive C"
End Sub
----------------------End Code------------------
I am using this on Windows XP, and C: drive is FAT32 (don't know if that makes any diff)... if I use Clng() I can get past the Run Time Errror, but then I get a result of 0 kilobytes.
Any help is greatly appreciated
John Vogel
john@thecompuwizard.com
-------------------Begin Code-------------------------
Private Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Function FreeDiskSpace(DriveLetter As String)
Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim FreeClusters As Long
Dim NumberOfClusters As Long
Dim ret As Long
ret = GetDiskFreeSpace(DriveLetter & ":\", SectorsPerCluster, BytesPerSector, FreeClusters, NumberOfClusters)
FreeDiskSpace = BytesPerSector * SectorsPerCluster * FreeClusters
End Function
Private Sub Command1_Click()
MsgBox FreeDiskSpace("C") \ 1024 & " Kb Free Space in Drive C"
End Sub
----------------------End Code------------------
I am using this on Windows XP, and C: drive is FAT32 (don't know if that makes any diff)... if I use Clng() I can get past the Run Time Errror, but then I get a result of 0 kilobytes.
Any help is greatly appreciated
John Vogel
john@thecompuwizard.com