Home > Tutorials > VB Tutorials


Programme

File Backupper

Digitize Plot To Data

Ready Replace

Scrabbler






Tutorials

Comsol 4.2 Tutorials

Gwyddion Tutorials

VB 6.0 Tutorials

Tutorials: sonst

 

VB Tutorials





VB 6.0
Tutorial: Freien Speicherplatz ermitteln

In diesem Tutorial ist gezeigt, wie man den freien Speicherplatz auf einem Laufwerk mit Hilfe einer Win32 API bestimmen kann. Es ist eine Funktion, die man ganz einfach in ein eigenes Projekt einbauen kann.

Lösung

So könnte ein einfaches Programm aussehen, welches diese Funktion verwendet:





Keywords:
VB6.0, Visual Basic 6
check free target space, Drive's physical free Space, free Disc Space, Total Disc Space
Win32 API





Runterladen dieses VB6.0 Projekts

Hier ist der Quelltext für dieses Projekt:


Option Explicit

'Dieser Source stammt von http://www.soft-hummingbird.com
'und kann frei verwendet werden. Für eventuelle Schäden
'wird nicht gehaftet.

'This source code originates from http://www.soft-hummingbird.com
'it is as-is without any warranty and can be used freely
'In no event shall the author be held liable for any damages arising from the use of this code





Private Declare Function SHGetDiskFreeSpace Lib "shell32" Alias "SHGetDiskFreeSpaceA" (ByVal pszVolume As String, pqwFreeCaller As Currency, pqwTot As Currency, pqwFree As Currency) As Long




Private Sub Command1_Click()
MsgBox "Free space on " & Text1 & vbCrLf & Format(CheckFreeSpaceOnDisc(Text1), "###,###,###,##0") & " Byte"
End Sub




'gibt die Anzahl der bytes zurück oder bei auftreten von fehler -1
'Benutzung: text1 = FileSizeH(CheckFreeSpaceOnDisc("c"))
Function CheckFreeSpaceOnDisc(ByVal Drive As String) As Currency
Dim FreeForCaller As Currency, Tot As Currency, Free As Currency

  On Error GoTo fehler
  If Drive = "" Then CheckFreeSpaceOnDisc = -1: Exit Function
  If Len(Drive) = 1 Then Drive = Drive & ":\"
  If Len(Drive) = 2 And Right$(Drive, 1) = ":" Then Drive = Drive & "\"
  SHGetDiskFreeSpace Drive, FreeForCaller, Tot, Free
  FreeForCaller = FreeForCaller * 10000
  Tot = Tot * 10000
  Free = Free * 10000
  'Format$(FreeForCaller, "###,###,###,##0") & " Byte"
 
CheckFreeSpaceOnDisc = FreeForCaller

Exit Function
fehler: CheckFreeSpaceOnDisc = -1
End Function




 


Zum runterladen für VB 6.0:
  (3 kB)







      Home      Impressum