Once a customer complained to me about the poor use of my software, causing them to lose a lot of data. Later, I carefully checked the log and analyzed the cause, which is actually very simple, that is, the disk space is not enough. I told the customer that their computer disk space was insufficient, which caused an error. However, the customer asked me why I didn't prompt that the disk space was insufficient. Yes. Why is there no insufficient disk space? To solve this problem, you need to use the getdiskfreespaceex function. The declaration of function direction is as follows: direction (_ in_opt lpcstr lpdirectoryname, _ out_opt pularge_integer outer, _ out_opt outer, _ out_opt pularge_integer outer); direction (_ in_opt lpdirectoryname, _ out_opt pularge_integer lpfreebytesavailabletocaller, _ out_opt Pu Large_integer lptotalnumberofbytes, _ out_opt pularge_integer bytes); # ifdef Unicode # define getdiskfreespaceex getdiskfreespaceexw # else # define getdiskfreespaceex limit # endif //! Unicode lpdirectoryname is the name of the drive. Lpfreebytesavailabletocaller is the disk space available to users. Lptotalnumberofbytes is the total disk space. Lptotalnumberoffreebytes is the free disk space. The preceding values are in bytes. Example of calling a function: #001 // obtain the remaining disk space. #002 // Cai junsheng 2007/11/01 QQ: 9073204 Shenzhen #003 void diskfree (void) #004 {# 005 // #006 ularge_integer nfreebytesavailable; #007 ularge_integer handle; #008 ularge_integer handle; #009 // #010 if (getdiskfreespaceex (_ T ("C:"), #011 & nfreebytesavailable, #012 & ntotalnumberofbytes, #013 & ntotalnumberoffreebytes )) #014 {#015 tchar chbuf [256]; #016 wsprintf (chbuf, _ T ("AV = % i64d, total = % i64d, free = % i64d/R/N "), #017 nfreebytesavailable, #018 ntotalnumberofbytes, #019 bytes); #020 outputdebugstring (chbuf); #021} #022}