Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

Code-Beispiel

Code-Beispiele » Dateien und Laufwerke

Belegten und freien Speicherplatz ermitteln..

Lizenz:Erster Autor:Letzte Bearbeitung:
k. A.Redakteurytwinky 13.04.2013

Ich will es gleich zu Anfang zugeben: Bei den USB-Sticks habe ich einen WorkAround benutzt(klingt etwas besser als: geschummelt ^^)
Alles was größer als 3MB ist und DriveTyp 2 hat, wird als USB-Stick angesehen..
Sonst gibt es eigentlich nicht viel zu sagen, außer(das ist aber sehr wichtig :D), daß das Programm mit der Compiler-Option -lang deprecated kompiliert werden muß. Ein Befehlszeilenaufruf wäre dann also: fbc volz.bas -lang deprecated
Benutzer der FBIde folgen einfach Externer Link! meinem Tutorial, nur setzen sie dann statt -s gui eben -lang deprecated ein ;-))
In puncto Sprachkompatibilität kann ich sagen, daß es in Englisch und in Deutsch bedient werden kann, ansonsten ist es auf Windows-Benutzer beschränkt..
Gruß
ytwinky

#include "vbcompat.bi"
'+-----------------------------------------------------------------------------------+
'|    Header: Bestimmen der Übergabeparameter                                        |
'|    AnzeigeCheck:|Il1 sind Alt-0124, Großes i, kleines L, Eins „ä”öüáߎę֚Üñ±¸©ø°|
Const Author="VolZ.Bas v0182b ¸2007 by ytwinky, MD"'                                 |
'|           (Tastenkombination: keine)                                              |
'|    ACHTUNG: Funktioniert nur mit -lang deprecated                                 |
'|    Zweck : Auflisten aller/vorhandener Laufwerke mit freien und belegten Byte[MB] |
'+-----------------------------------------------------------------------------------+
Type LwRec
  As ULongInt FreeUserBytes, TotalBytes, TotalFree
End Type

Const Esc=!"\27", Lf=!"\n", Rot=4, Hell=8,  vk=8, MB=1024*1024
Dim As String m, dn, Prt
Dim Lw(1 To 26) As LwRec
Dim LwTyp(1, 5) As String={{"Unbekannt", "Fehlt", "Disk-Lw", "FestPlatte", "NetzLw", "CD/DVD"}, _
                           {"unknown", "missing", "Disk-Drive", "Hard-Disk", "Net-Drive", "CD/DVD"}}
Dim Lng(1, 1 To 9) As String={{"Jedes Lw", "Vorhandene Lw", "Was denn nun(Esc=Abbruch)", _
                               "Lw", "Total[MB]", "Frei[MB]", "Typ", "JV", "Zeige"}, _
                              {"every drive", "available drives", "Enter your choice(Esc=Abort)", _
                               "Dr", "Total[MB]", "Free[MB]", "Type", "EA", "Show"}}
Dim As Integer i, j, TypNr, LngSel
Width 48, 20
Declare Function GetDriveType Alias "GetDriveTypeA" (byVal nDrive As String) As Integer
Declare Function GetDriveSpecs Lib "kernel32" Alias "GetDiskFreeSpaceExA"_
  (byVal lpRootPathName As String, lpFreeBytesAvailableToCaller As ULongInt, _
  lpTotalNumberOfBytes As ULongInt, lpTotalNumberOfFreeBytes As ULongInt) As Integer

Function ShowDriveSpecs(dn As String, Lw As LwRec) As LwRec
  Dim As Integer Back
  Dim As ULongInt FreeUserBytes, TotalBytes, TotalFree
  Lw.TotalBytes=0
  If dn[0]<67 Then Return Lw
  Back=GetDriveSpecs(dn, Lw.FreeUserBytes, Lw.TotalBytes, Lw.TotalFree)
  Return Lw
End Function

Function FormatIt(byVal Value As Single) As String
  Dim As String s=Format(Value, String(vk, "#") &".0")
  If Value<=0 Then s=Space(vk+Len(Str(Value))+1) Else s=Space(Vk-Len(s)+2) &s
  Function=s
End Function

Function MenuChar(s As String, First As Integer=1, nVG As Integer=Hell+Rot) As String
  Dim As Integer cVG=LoWord(Color)
  If First<>1 Then Print Left(s, First-1);
  Color nVG
  Print Chr(s[First-1]);
  Color cVG
  Return Mid(s, First+1)
End Function

'Main
m=UCase(Command(1))
If m="" Then
  If m<>"E" And m<>"D" Then
    Print MenuChar("Soll die Ausgabe deutsch sein?", 18)
    Print MenuChar("Do you prefer english?", 15)
    Print Lng(0, 3) &Lf &Lng(1, 3) &"(d | e )?:";
    Do
      m=UCase(Inkey)
      Sleep 1
    Loop Until Instr("DE" &Esc, m)>0
    Print m
  End If
End If
LngSel=Abs(m="E")
m=Ucase(Command(2))
If m="" Then
  Print Lng(LngSel, 9)
  Print MenuChar(Lng(LngSel, 1))
  Print MenuChar(Lng(LngSel, 2))
  Print Lng(LngSel, 3) &"(" &Lng(LngSel, 8) &"):";
  Do
    m=UCase(Inkey)
    Sleep 1
  Loop Until Instr(Lng(LngSel, 8) &Esc, m)>0
  If m<>Esc Then Print m; Else End
End If
Prt=Author &Lf
Prt+=Lng(LngSel, 4) &Space(Vk-5) &Lng(LngSel, 5) &Space(Vk-5) &Lng(LngSel, 6) &Space(Vk-7) &Lng(LngSel, 7)
For i=1 to 26
  With Lw(i)
    dn=Chr(64+i) &":"
    TypNr=GetDriveType(dn)
    If (TypNr+(m=Right(Lng(LngSel, 8), 1)))>=1 Then
      j+=1
      Lw(i)=ShowDriveSpecs(dn, Lw(i))
      Prt+=Lf &dn &"  " &FormatIt(Lw(i).TotalBytes\MB) &" " &FormatIt(Lw(i).TotalFree\MB) &" "
      If TypNr=2 Then
        Prt+=*IIF(Abs(Lw(i).TotalBytes)>3, @"USB", @"Floppy") 'everything>3MB is considered to be a USB-Drive/-Stick
      Else
        Prt+=LwTyp(LngSel, TypNr)
      End If
    End If
  End With
Next
Cls
Width 38, j+3
Print Prt &Lf &"Eniki..";
Sleep

Zusätzliche Informationen und Funktionen
  • Das Code-Beispiel wurde am 15.08.2007 von Redakteurytwinky angelegt.
  • Die aktuellste Version wurde am 13.04.2013 von RedakteurMOD gespeichert.
  Bearbeiten Bearbeiten  

  Versionen Versionen