Problemas com Função DiskFree()
Delphi4
função DiskFree(0)
Esta função retorna o espaço livre em bytes do HD, em algumas máquinas com win98 a função retorna valor negativo.
Alguém sabe porque acontece isso ?
Obrigado
função DiskFree(0)
Esta função retorna o espaço livre em bytes do HD, em algumas máquinas com win98 a função retorna valor negativo.
Alguém sabe porque acontece isso ?
Obrigado
Anonymous
Curtidas 0
Respostas
Anonymous
25/03/2003
também tenho esse problema, mas no Win XP
por favor se alguma alma, souber da solução coloque, para nos a resposta
...valeu ... até mais
Edson
por favor se alguma alma, souber da solução coloque, para nos a resposta
...valeu ... até mais
Edson
GOSTEI 0
Aroldo Zanela
25/03/2003
DiskFree returns -1 if the drive number is invalid.
É isso?
É isso?
GOSTEI 0
Anonymous
25/03/2003
não, -1 é uma unidade invalida...ok
o que esta retornando é o espaço, ou sei la que valor aquele,
todo negativo
no meu HD retorna -2952....etc
o que esta retornando é o espaço, ou sei la que valor aquele,
todo negativo
no meu HD retorna -2952....etc
GOSTEI 0
Aroldo Zanela
25/03/2003
Caro Cirilo,
A função Diskfree é implementada pelo uso de InternalGetDiskSpace, que por sua vez é implementada por GetDiskFreeSpaceEx (API) ou BackfillGetDiskFreeSpaceEx. Apesar de nunca ter presenciado algum problema, fiquei preocupado com o seguinte comentário encontrado na unit windows:
The GetDiskFreeSpace Win32 API does not support partitions larger than 2GB
under Win95. A new Win32 function, GetDiskFreeSpaceEx, supports partitions
larger than 2GB but only exists on Win NT 4.0 and Win95 OSR2.
The GetDiskFreeSpaceEx function pointer variable below will be initialized
at startup to point to either the actual OS API function if it exists on
the system, or to an internal Delphi function if it does not. When running
on Win95 pre-OSR2, the output of this function will still be limited to
the 2GB range reported by Win95, but at least you don´t have to worry
about which API function to call in code you write. }
Vou verificar nas informações técnicas da borland e ver se consigo mais alguma dica.
A função Diskfree é implementada pelo uso de InternalGetDiskSpace, que por sua vez é implementada por GetDiskFreeSpaceEx (API) ou BackfillGetDiskFreeSpaceEx. Apesar de nunca ter presenciado algum problema, fiquei preocupado com o seguinte comentário encontrado na unit windows:
The GetDiskFreeSpace Win32 API does not support partitions larger than 2GB
under Win95. A new Win32 function, GetDiskFreeSpaceEx, supports partitions
larger than 2GB but only exists on Win NT 4.0 and Win95 OSR2.
The GetDiskFreeSpaceEx function pointer variable below will be initialized
at startup to point to either the actual OS API function if it exists on
the system, or to an internal Delphi function if it does not. When running
on Win95 pre-OSR2, the output of this function will still be limited to
the 2GB range reported by Win95, but at least you don´t have to worry
about which API function to call in code you write. }
Vou verificar nas informações técnicas da borland e ver se consigo mais alguma dica.
GOSTEI 0
Aroldo Zanela
25/03/2003
Cirilo,
Como você está utilizando a versão 4 e eu verifiquei as implementações em Delphi 7, talvez a função abaixo ainda não esteja implementada na sua versão. Se puder, faça um teste com o exemplo da FAQ abaixo:
------------
community.borland.com
Article #17552: Checking available disk space on large drives.
Question and Answer Database
FAQ2552D.txt Checking available disk space on large drives.
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I check for available diskspace on a drive larger than 2
gigabytes?
Answer:
You will need to call the Windows API function GetDiskFreeSpaceEx()
and convert the returned integers to doubles, since integers greater
than 2 gigabytes are not supported in Delphi.
Example:
7/16/98 4:31:28 PM
Last Modified: 01-SEP-99
Boa sorte,
Como você está utilizando a versão 4 e eu verifiquei as implementações em Delphi 7, talvez a função abaixo ainda não esteja implementada na sua versão. Se puder, faça um teste com o exemplo da FAQ abaixo:
------------
community.borland.com
Article #17552: Checking available disk space on large drives.
Question and Answer Database
FAQ2552D.txt Checking available disk space on large drives.
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I check for available diskspace on a drive larger than 2
gigabytes?
Answer:
You will need to call the Windows API function GetDiskFreeSpaceEx()
and convert the returned integers to doubles, since integers greater
than 2 gigabytes are not supported in Delphi.
Example:
function GetDiskFreeSpaceEx(lpDirectoryName: PAnsiChar; var lpFreeBytesAvailableToCaller : Integer; var lpTotalNumberOfBytes: Integer; var lpTotalNumberOfFreeBytes: Integer) : bool; stdcall; external kernel32 name ´GetDiskFreeSpaceExA´; procedure GetDiskSizeAvail(TheDrive : PChar; var TotalBytes : double; var TotalFree : double); var AvailToCall : integer; TheSize : integer; FreeAvail : integer; begin GetDiskFreeSpaceEx(TheDrive, AvailToCall, TheSize, FreeAvail); {$IFOPT Q+} {$DEFINE TURNOVERFLOWON} {$Q-} {$ENDIF} if TheSize >= 0 then TotalBytes := TheSize else if TheSize = -1 then begin TotalBytes := $7FFFFFFF; TotalBytes := TotalBytes * 2; TotalBytes := TotalBytes + 1; end else begin TotalBytes := $7FFFFFFF; TotalBytes := TotalBytes + abs($7FFFFFFF - TheSize); end; if AvailToCall >= 0 then TotalFree := AvailToCall else if AvailToCall = -1 then begin TotalFree := $7FFFFFFF; TotalFree := TotalFree * 2; TotalFree := TotalFree + 1; end else begin TotalFree := $7FFFFFFF; TotalFree := TotalFree + abs($7FFFFFFF - AvailToCall); end; end; procedure TForm1.Button1Click(Sender: TObject); var TotalBytes : double; TotalFree : double; begin GetDiskSizeAvail(´C:\´, TotalBytes, TotalFree); ShowMessage(FloatToStr(TotalBytes)); ShowMessage(FloatToStr(TotalFree)); end;
7/16/98 4:31:28 PM
Last Modified: 01-SEP-99
Boa sorte,
GOSTEI 0