示例代码:DWORD CCommonFun::GetDesignatedDiskFreeSpace(const CString &szPath)
{
DWORD dwTotalDiskSpace,dwFreeDiskSpace,dwUsedDiskSpace;
ULARGE_INTEGER uiFreeBytesAvailableToCaller;
ULARGE_INTEGER uiTotalNumberOfBytes;
ULARGE_INTEGER uiTotalNumberOfFreeBytes;
if(GetDiskFreeSpaceEx(szPath, &uiFreeBytesAvailableToCaller,
&uiTotalNumberOfBytes,
&uiTotalNumberOfFreeBytes))
{
dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
TRACE("硬盘%s::总空间%dMB, 已用%dMB, 可用%dMB\n", szPath,
dwTotalDiskSpace, dwUsedDiskSpace, dwFreeDiskSpace);
return dwFreeDiskSpace;
}
return -1;
}
posted on 2013-01-16 17:00
王海光 阅读(2898)
评论(0) 编辑 收藏 引用 所属分类:
MFC