MSDN says that the GetFreeDiskSpaceEx API returns ULARGE_INTEGERS and it also says that be careful not to truncate them to 32 bits.

Now in masm32 they are defined as DWORDs and to my understanding DWORDs are just 32bits.

My program is getting sometimes (depending the amount of freespace on disk) zero freespace.

So, the problem is how to get GetFreeDiskSpaceEx API to work correctly under masm32?

Best Regards, Sami
Posted on 2002-03-26 02:49:33 by SamiP
IIRC, the ULARGE_INTEGER type is actually 64 bits (it has to be, to hold the numbers required).

Also another thing to note: you are dealing with pointers to ULARGE_INTs during the call, you are not dealing with the numbers directly. The function returns zero if it fails, so check eax for zero after calling the function. If it does fail, what is the error code returned in a call to GetLastError?
Posted on 2002-03-26 05:26:22 by sluggy
GetFreeDiskSpaceEx requires pointers to 64 bit fields for the available, total and free space, as well as the drive. Use ADDR for these operands on the INVOKE.

spavail dq 0
sptotal dq 0

cdrive db "C:\", 0

invoke GetDiskFreeSpaceEx, addr cdrive, addr spavail, addr sptotal, NULL


PS - If you want to convert a QWORD to ASCII, see this thread:

Posted on 2002-03-26 06:02:57 by S/390

My problem was, that I declared my variables as DWORD. Now I have declared them as QWORD and everything works fine.

Kind Regards, Sami
Posted on 2002-03-26 07:53:50 by SamiP