Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Jul : Get partion free space

www.cryer.info
Managed Newsgroup Archive

Get partion free space

Subject:Get partion free space
Posted by:"Anthoni Gardner" (no..@nono.com)
Date:Tue, 31 Jul 2007 11:13:45

Hello,

I thought I had code for this already, but must have deleted it. I know I've
done it before :)
What I want to do is iterate through a user's partitions looking for the one
with the largest free space. At the moment I have this code:-

<code>
Var
  Drive: Char;
  DriveLetter: String[4];

Begin
  For Drive := 'C' To 'Z' Do
  Begin
    DriveLetter := Drive + ':\';
    case GetDriveType(PChar(Drive + ':\')) of
      DRIVE_FIXED:
        Begin
            //Here I want to get the free space of this drive so I can store
it for later use.
            //Preferably in an integer / double format so its easy to
compare.
        End;
    end;
  End;
End;
</code>

When I detect that a drive is fixed I want to get the free space as told by
windows.
I then want to sort the list somehow, with the largest size on top, so i
know what the biggest one is. Naturally if there is just one partition in
then it is usually C: but not all users do this (I know I dont). I know
there is an api for this but no amount of searching Google seems to bring it
forward.

Any pointers on this would be greatly appreciated.

Regards
Anthoni

Replies:

www.cryer.info
Managed Newsgroup Archive