Hallo Ewok,
stimmt das gleiche Problem hatte ich auch.
verwende lieber mal folgendes (PS: dieser Code ist sofort Fertig und muss nicht erst die gesammte Festplatte durchlaufen!)
In eine Form:Option Explicit
Private Sub Form_Load()
Dim bDriveExist As Boolean
Dim sPath As String
Dim dTotalSpace As Double
Dim dFreeSpace As Double
Dim dUsedSpace As Double
sPath = "C"
bDriveExist = Get_Disk_Space(sPath, dTotalSpace, dFreeSpace, dUsedSpace)
If bDriveExist = True Then
MsgBox "Festplattengröße von " & sPath & ": ist " & dTotalSpace & "" & _
"Bytes" & vbCrLf & _
"Noch Freier Speicher " & dFreeSpace & " Bytes" & vbCrLf & _
"zur Zeit verwendet " & dUsedSpace & " Bytes"
Else
MsgBox "Fehler"
End If
End Sub Ins Modul:Option Explicit
' ---------------------------------------------------------------------------
' Needed to determine space requirements of a drive
' ---------------------------------------------------------------------------
' Do we have the ability to use GetDiskFreeSpaceEx
Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
' Verify the proceedure address within the kernel32 dll
Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal hModule As Long, ByVal lpProcName As String) As Long
' Decrement the DLL counter when we are finished. This is
' our safety net.
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
' Drives over 2GB (2,147,483,647 bytes)
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, _
FreeBytesAvailableToCaller As Currency, _
TotalNumberOfBytes As Currency, _
TotalNumberOfFreeBytes As Currency) As Long
' Drives under 2GB (2,147,483,647 bytes)
Private Declare Function GetDiskFreeSpace Lib "kernel32" _
Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _
lpSectorsPerCluster As Long, lpBytesPerSector As Long, _
lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As _
Long
Public Function Get_Disk_Space(ByVal strPath As String, _
dblTotalSpace As Double, _
dblFreeSpace As Double, _
dblUsedSpace As Double) As Boolean
' ***************************************************************************
' Routine: Get_Disk_Space
'
' Description: Get the total number of bytes, total number of free bytes,
' and total number of used bytes on a hard drive. This will
' also determine which API call to make based on the size of
' the drive.
'
' Parameters: strDriveLtr - drive to be queried (ex: C:)
' dblTotalSpace - Value to be returned
' dblFreeSpace - Value to be returned
' dblUsedSpace - Value to be returned
'
' Returns: Total number of bytes, total number of free bytes, and total
' number of used bytes on a drive.
'
' ===========================================================================
' DATE NAME DESCRIPTION
' ----------- --------------- ---------------------------------------------
' 03-MAR-2000 Kenneth Ives Wrote routine
' 14-MAR-2000 Kenneth Ives Modified and documented to handle under and
' over 2gb drives
' *************************************************************************** *greetz*
Tim
.
http://www.DotNetWorld.de |