Get Disk Drive Capacity
#3
In QB64 you can use a Windows API for this.
Code: (Select All)

DECLARE DYNAMIC LIBRARY "kernel32"
        function GetDiskFreeSpaceEx% alias "GetDiskFreeSpaceExA" (_
        lpDirectoryName as STRING, _
        lpFreeBytesAvailableToMe As _UNSIGNED LONG, _
        lpTotalNumberOfBytes As _UNSIGNED LONG, _
        lpTotalNumberOfFreeBytes As _UNSIGNED LONG)
END DECLARE

DIM DriveOrFolder AS STRING
DIM FreeBytesAvailableToMe AS _UNSIGNED LONG
DIM TotalBytes AS _UNSIGNED LONG
DIM FreeBytes AS _UNSIGNED LONG


DriveOrFolder = "C:\"

FetchResult = GetDiskFreeSpaceEx(DriveOrFolder, FreeBytesAvailableToMe, TotalBytes, FreeBytes)

PRINT "Path: '" + DriveOrFolder + "'"
PRINT "Path founding (1 - ok, 0 - ERROR):" + STR$(FetchResult)
PRINT "------------------------------------"
PRINT "TotalBytes:              " + STR$(TotalBytes)
PRINT "FreeBytes Avilable To Me: " + STR$(FreeBytesAvailableToMe)
PRINT "FreeBytes:                " + STR$(FreeBytes)

Edit:
If you use the data type _UNSIGNED _INTEGER64, you can read larger disk sizes.
_UNSIGNED LONG is for < 4 GB media.
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: 6 Guest(s)