GetDiskFreeSpaceEx报告错误的空闲字节数 [英] GetDiskFreeSpaceEx reports wrong number of free bytes

查看:200
本文介绍了GetDiskFreeSpaceEx报告错误的空闲字节数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

__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);

我正在开发一个数据管理例程,它是一个Windows CE命令行应用程序。上面的代码显示了如何获取特定驱动器上的空闲字节数,其中包含文件夹Manager.capdir(它是包含目录的完整路径名的变量)。

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 which contains the folder Manager.capdir (it is the variable containing the full path name of the directory).

我的问题是,上述代码(_tprintf语句)报告的空闲字节数与驱动器的空闲字节数不匹配(我通过右键单击驱动器进行检查)。

My question is, the number of free bytes reported by the above code (the _tprintf statement) doesn't match with the number of free bytes of the drive (which i check by doing a right click on the drive).

我想知道这种差异的原因吗?

I wish to know if the reason for this difference?

推荐答案

我有一个没有磁盘配额运行的单用户计算机。我将您的代码发布到基于对话框的MFC应用程序并运行它,与单个条件,我使用C:\作为lpDirectoryName参数,所以我可以与系统报告的驱动器可用空间进行比较。这似乎是合理的,因为自由空间只对驱动器而不是文件夹有意义。

I have a single-user machine with no disk quota in operation. I posted your code into a dialog based MFC application and ran it, with the single proviso that I used "C:\" as the lpDirectoryName parameter so I could compare against the drive free space as reported by the system. That seemed logical as free space is only meaningful for a drive, not a folder.

刚开始我以为我看到一个类似的问题,检查(我将其绑定到一个按钮),并得到与属性对话框在那一刻相同的结果。看起来驱动器上的可用空间是一个相当动态的数量 - 如果是系统驱动器,这不是太可怕了 - 甚至没有其他海报相当正确报告的标准,您可能看不到与属性完全相同的数字对话框报告。

At first I thought that I was seeing a similar problem, but then I re-ran the check (I tied it to a button), and got the same result as the properties dialog at that moment. It seems the free space on a drive is a fairly dynamic quantity - this is not terribly suprising if it is the system drive - and even absent the criteria that other posters have quite correctly reported, you may not see precisely the same number as the properties dialog reports at the moment it was run.

这篇关于GetDiskFreeSpaceEx报告错误的空闲字节数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆