Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Disk Drive Capacity
#6
Quote:I also found something like that.
@Stefan-68, useful program. Did you program it yourself or where did you find it? The explanation would be important to me with regard to the declaration of the "library".

I have modified it a bit so that one can specify the drives.

Code: (Select All)
'Stefan68, Belegung eines Speichermediums ermitteln - 3. Juli 2023

Option _Explicit

Const DRIVE_UNKNOWN = 0
Const DRIVE_NO_ROOT_DIR = 1
Const DRIVE_REMOVABLE = 2
Const DRIVE_FIXED = 3
Const DRIVE_REMOTE = 4
Const DRIVE_CDROM = 5
Const DRIVE_RAMDISK = 6

Declare Dynamic Library "Kernel32"
  Function GetDiskFreeSpace% Alias GetDiskFreeSpaceExA (lpDirectoryName As String, Byval lpFreeBytesAvailableToCaller As _Offset, Byval lpTotalNumberOfBytes As _Offset, Byval lpTotalNumberOfFreeBytes As _Offset)
  Function GetDriveType~& Alias GetDriveTypeA (lpRootPathName As String)
End Declare

Dim totalFreeBytesOnDisk As _Unsigned _Integer64
Dim laufwerk As String * 3

Locate 3, 3
Print "Zeigt die Belegung der Laufwerke an"
Locate 4, 3
Print "==================================="

Locate 6, 3
Input "Laufwerksbustabe (z.B. C:): ", laufwerk

Locate CsrLin + 1, 3
If GetDiskFreeSpace(laufwerk, 0, 0, _Offset(totalFreeBytesOnDisk)) Then
  Select Case totalFreeBytesOnDisk
    Case Is < 1024
      Print Using "    ####, B Available"; totalFreeBytesOnDisk,
    Case Is < (1024 ^ 2) And totalFreeBytesOnDisk >= 1024
      Print Using "####,.## KB Available"; (totalFreeBytesOnDisk / 1024)
    Case Is < (1024 ^ 3) And totalFreeBytesOnDisk >= (1024 ^ 2)
      Print Using "####,.## MB Available"; (totalFreeBytesOnDisk / (1024 ^ 2))
    Case Is < (1024 ^ 4) And totalFreeBytesOnDisk >= (1024 ^ 3)
      Print Using "####,.## GB Available"; (totalFreeBytesOnDisk / (1024 ^ 3))
    Case Is < (1024 ^ 5) And totalFreeBytesOnDisk >= (1024 ^ 4)
      Print Using "####,.## TB Available"; (totalFreeBytesOnDisk / (1024 ^ 4))
  End Select
End If

Locate CsrLin + 2, 3
Beep
Select Case GetDriveType(laufwerk)
  Case DRIVE_UNKNOWN
    Print "Unkown drive type"
  Case DRIVE_NO_ROOT_DIR
    Print "Invalid path"
  Case DRIVE_REMOVABLE
    Print "Removable media"
  Case DRIVE_FIXED
    Print "Fixed media"
  Case DRIVE_REMOTE
    Print "Network media"
  Case DRIVE_CDROM
    Print "CD-ROM drive"
  Case DRIVE_RAMDISK
    Print "RAM disk"
End Select
Reply


Messages In This Thread
Get Disk Drive Capacity - by BDS107 - 07-03-2023, 04:30 PM
RE: Get Disk Drive Capacity - by SMcNeill - 07-03-2023, 05:02 PM
RE: Get Disk Drive Capacity - by SagaraS - 07-03-2023, 05:39 PM
RE: Get Disk Drive Capacity - by Steffan-68 - 07-03-2023, 07:20 PM
RE: Get Disk Drive Capacity - by SagaraS - 07-03-2023, 07:31 PM
RE: Get Disk Drive Capacity - by Kernelpanic - 07-05-2023, 03:49 PM
RE: Get Disk Drive Capacity - by Ultraman - 07-05-2023, 03:56 PM
RE: Get Disk Drive Capacity - by Kernelpanic - 07-05-2023, 04:04 PM
RE: Get Disk Drive Capacity - by Steffan-68 - 07-05-2023, 05:24 PM
RE: Get Disk Drive Capacity - by Ultraman - 07-05-2023, 05:29 PM
RE: Get Disk Drive Capacity - by Ultraman - 07-05-2023, 04:02 PM
RE: Get Disk Drive Capacity - by SMcNeill - 07-05-2023, 04:42 PM
RE: Get Disk Drive Capacity - by Ultraman - 07-05-2023, 04:55 PM
RE: Get Disk Drive Capacity - by eoredson - 07-07-2023, 01:52 AM
RE: Get Disk Drive Capacity - by Ultraman - 07-07-2023, 12:01 PM



Users browsing this thread: 4 Guest(s)