Board index » delphi » _GetDiskFreeSpace Help!!!

_GetDiskFreeSpace Help!!!

Hi! I'm currently writing a program which needs to know the amount of free
hard drive space. I 've tried to use GetDiskFreeSpace Win32 API call but i
don't know exactly how to use it.

I think i put the wrong variable type.

Can someone tell me how to use it?
With some examples.

e-mail directly to chiw...@sprint.ca
or post the answer message to comp.lang.pascal.delphi.misc

Thank you, 1998/2/21

 

Re:_GetDiskFreeSpace Help!!!


Hi  "Wein Chien" !:

Quote
>Hi! I'm currently writing a program which needs to know the amount of free
>hard drive space. I 've tried to use GetDiskFreeSpace Win32 API call but i
>don't know exactly how to use it.

Some days ago i have written this function to get the size of free disk space.
With this function you will get the right result, even when the HD has more
than
2GB of capacity!

type     tDrvData = record
                      SectorsPerCluster,
                      BytesPerSector,
                      NumberOfFreeClusters,
                      TotalNumberOfClusters : DWORD;
                    end;
var     DrvData : tDrvData;

function DskFree(ActDrv : pChar) : extended;
begin
  with DrvData do
  begin
    GetDiskFreeSpace(ActDrv,
                                 SectorsPerCluster,
                                 BytesPerSector,
                                 NumberOfFreeClusters,
                                 TotalNumberOfClusters);
    DskFree := BytesPerSector * SectorsPerCluster * NumberOfFreeClusters;
  end;
end;

Just make a call like this:   "FreeSpace := DskFree('C:\');"
Don't forget to add the backslash !

with kind regards, Torsten

Re:_GetDiskFreeSpace Help!!!


In article <888079639.816346@michelob>,
  "Wein Chien" <chiw...@sprint.ca> wrote:

Quote

> Hi! I'm currently writing a program which needs to know the amount of free
> hard drive space. I 've tried to use GetDiskFreeSpace Win32 API call but i
> don't know exactly how to use it.

> I think i put the wrong variable type.

> Can someone tell me how to use it?
> With some examples.

there is a function DiskFree(Drive: Byte)
surprisingly,there is also an example on Delphi's help....(how did Borland
chose the twelve functions that they have examples for on the help ???
*smile*)

-barvaz

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Re:_GetDiskFreeSpace Help!!!


On Sat, 21 Feb 1998 11:47:00 -0500, "Wein Chien" <chiw...@sprint.ca>
wrote:

Quote
>Hi! I'm currently writing a program which needs to know the amount of free
>hard drive space. I 've tried to use GetDiskFreeSpace Win32 API call but i
>don't know exactly how to use it.

>I think i put the wrong variable type.

>Can someone tell me how to use it?
>With some examples.

there is a function DiskFree(Drive: Byte)
surprisingly,there is also an example on Delphi's help....(how did
Borland chose the twelve functions that they have examples for on the
help ???  *smile*)

-barvaz

Re:_GetDiskFreeSpace Help!!!


Use the DiskFree function - why bother with API calls ?

function DiskFree(Drive: Byte): Integer;

Description
DiskFree returns the number of free bytes on the specified drive
number, where 0 = Current, 1 = A, 2 = B, and so on.
DiskFree returns -1 if the drive number is invalid.

Example
var
  S: string;
begin
  S := IntToStr(DiskFree(0) div 1024) + ' Kbytes free.';
  Canvas.TextOut(10, 10, S);
end;

Hope that helps...
Cheers,
Michael.

On Sat, 21 Feb 1998 14:04:19 -0500, "Wein Chien" <chiw...@sprint.ca>
wrote:

Quote

>Hi! I'm currently writing a program which needs to know the amount of free
>hard drive space. I 've tried to use GetDiskFreeSpace Win32 API call but i
>don't know exactly how to use it.

>I think i put the wrong variable type.

>Can someone tell me how to use it?
>With some examples.

>e-mail directly to chiw...@sprint.ca
>or post the answer message to comp.lang.pascal.delphi.misc

>Thank you, 1998/2/21

Re:_GetDiskFreeSpace Help!!!


Do NOT use DiskFree in the era  of 4+ GB drives. The return value is
Integer and cannot hold more than 4 GB.

Use Torsten Beekhuis' code instead.

Bernd Cordes
www.leanware.com
Maker of Backer
- Change lanware to leanware for email -

Other Threads