GetDiskFreeSpaceEx reports incorrect number of free bytes

__int64 i64FreeBytes
unsigned __int64 lpFreeBytesAvailableToCaller,
                 lpTotalNumberOfBytes,
                 lpTotalNumberOfFreeBytes; // variables used to obtain 
                                           // the free space on the  drive

GetDiskFreeSpaceEx (Manager.capDir,
(PULARGE_INTEGER)&lpFreeBytesAvailableToCaller,
(PULARGE_INTEGER)&lpTotalNumberOfBytes,
(PULARGE_INTEGER)&lpTotalNumberOfFreeBytes);

i64FreeBytes = lpTotalNumberOfFreeBytes;
_tprintf(_T ("Number of bytes free on the drive:%I64u \n"),
     lpTotalNumberOfFreeBytes);

I am working on a data management routine, which is a Windows CE command-line application. The above code shows how I get the number of free bytes on a particular drive that contains the Manager.capdir folder (this is a variable containing the full path to the directory).

My question is that the number of free bytes transmitted by the above code (the _tprintf operator) does not match the number of free bytes of the disk (which I check by right-clicking on the disk).

I want to know if the reason for this difference is?

+3
source share
3 answers

, . MFC , , "C: \" lpDirectoryName, , . , , .

, , ( ) , . , - - , - , , , .

+1

( ) GetDiskFreeSpaceEx, :

lpFreeBytesAvailable [out, optional] -

, , .

NULL.

, .

lpTotalNumberOfBytes [out, optional] -

, , .

NULL.

, .

, IOCTL_DISK_GET_LENGTH_INFO.

, , , , lpFreeBytesAvailable.

+1

. , , ( 8 ). , , , , . , .

, , .

0

Source: https://habr.com/ru/post/1704456/


All Articles