Author Topic: HDD free space  (Read 2728 times)

0 Members and 1 Guest are viewing this topic.

Offline Mad Axeman

  • Newbie
  • Posts: 74
    • View Profile
    • My web site - Harrythetrout
HDD free space
« on: April 02, 2021, 05:04:33 pm »
Hi Folks

My brain has gone totally blank on this. Is there a simple way to find out how much free space there is on a drive ? I know I can pipe a DIR output to a file and read that in but surely there's a nice built in command to get the free space or am I just imagining it ??
Oh look - a sig file :-)

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: HDD free space
« Reply #1 on: April 03, 2021, 02:48:59 am »

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: HDD free space
« Reply #2 on: April 03, 2021, 04:09:17 am »
uni$ = "C"

R = GetDiskFreeSpaceExA(uni$ + ":\" + CHR$(0), free~&&, total~&&, free2~&&)

IF R THEN
    vo$ = STR$(free~&&):  vo1$ = STR$(total~&&)
    PRINT "Free space  = "; vo$:    PRINT "Total space = "; vo1$
    INPUT k$
END IF

END

'qb64 x64
DECLARE DYNAMIC LIBRARY "kernel32"
 FUNCTION GetDiskFreeSpaceExA& (filename$, free AS _UNSIGNED _INTEGER64, total AS _UNSIGNED _INTEGER64, free2 AS _UNSIGNED _INTEGER64)
END DECLARE


« Last Edit: April 03, 2021, 04:28:33 am by euklides »
Why not yes ?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: HDD free space
« Reply #3 on: April 03, 2021, 11:22:40 am »
Yeah both euclides and spriggsy works (Windows 10), don't know why euclides has INPUT k$ unless using that as SLEEP function.

With Spriggsy's you might not want to test drive L:

I always thought you had to do the Declares first.
« Last Edit: April 03, 2021, 11:45:35 am by bplus »

Offline Mad Axeman

  • Newbie
  • Posts: 74
    • View Profile
    • My web site - Harrythetrout
Re: HDD free space
« Reply #4 on: April 03, 2021, 06:53:11 pm »
Thanks for the replies. All sorted now. I was a bit worried about euklides  post as it mentions QB64 x64 and I'm running the prog I'm writing on a 32 bit Win7 PC but it works fine.

Isn't it about time QB64 had it's own keyword for this? It's useful to know how much drive space you have  when you are writing what could maybe become very large files.
Oh look - a sig file :-)