[fpc-pascal]Win32 API Call
Gabor DEAK JAHN
djg at tramontana.co.hu
Fri Dec 7 19:47:33 CET 2001
At 12/7/2001 11:53 AM, you wrote:
Jim,
> I'm trying to call the Win32 API function GetDiskFreeSpaceEx, but when I do
> the compiler complains and I get the following error: Incompatible type
for
> arg no. 4: Got "pLongint", expected "PLARGEINTEGER"
Several problems and you're innocent in one of them... :-))
First, your variables are Longints which are to small (32 bit) for a
LARGE_INTEGER (64 bit)--an unsigned longint could only count to 4 GB which
is pretty small for a HDD today. Second, there is a typo in Redef.inc (and
the libraries generated) that should be corrected by the developers: in the
three lines declaring the various flavors of GetDiskFreeSpaceEx,
'lpTotalNumberOfBytes' should be followed by a comma, not a semicolon.
But in the meantime, you can call it like this (note that, although you can,
you don't have to allocate your simple variables dynamically):
{$APPTYPE CONSOLE}
program SI;
uses
Windows;
var
BytesAvail, BytesTotal, BytesFree : int64;
begin
GetDiskFreeSpaceEx ('G:\', BytesAvail, BytesTotal, @BytesFree);
writeln (BytesAvail, ' free bytes for user');
writeln (BytesTotal, ' bytes total for user');
writeln (BytesFree, ' free bytes on disk');
end.
Bye,
Gábor
-------------------------------------------------------------------
Gabor DEAK JAHN -- Budapest, Hungary.
E-mail: djg at tramontana.co.hu
More information about the fpc-pascal
mailing list