得到磁盘上剩余空间的值
2009-01-14 21:10
309 查看
GetDiskFreeSpace
The GetDiskFreeSpace function retrieves information about the specified disk, including the amount of free space on the disk.This function has been superseded by the GetDiskFreeSpaceEx function. New Win32-based applications should use GetDiskFreeSpaceEx.
BOOL GetDiskFreeSpace( LPCTSTR lpRootPathName, // pointer to root path LPDWORD lpSectorsPerCluster, // pointer to sectors per cluster LPDWORD lpBytesPerSector, // pointer to bytes per sector LPDWORD lpNumberOfFreeClusters, // pointer to number of free clusters LPDWORD lpTotalNumberOfClusters // pointer to total number of clusters );
Parameters
lpRootPathName Pointer to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify //MyServer/MyShare as //MyServer/MyShare/.Windows 95: The initial release of Windows 95 does not support UNC paths for the lpszRootPathName parameter. To query the free disk space using a UNC path, temporarily map the UNC path to a drive letter, query the free disk space on the drive, then remove the temporary mapping. Windows 95 OSR2 and later: UNC paths are supported.
lpSectorsPerCluster Pointer to a variable for the number of sectors per cluster. lpBytesPerSector Pointer to a variable for the number of bytes per sector. lpNumberOfFreeClusters Pointer to a variable for the total number of free clusters on the disk that are available to the user associated with the calling thread.
Windows NT 5.0 and later: If per-user disk quotas are in use, this value may be less than the total number of free clusters on the disk.
lpTotalNumberOfClusters Pointer to a variable for the total number of clusters on the disk that are available to the user associated with the calling thread.
Windows NT 5.0 and later: If per-user disk quotas are in use, this value may be less than the total number of clusters on the disk.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The GetDiskFreeSpaceEx function lets you avoid the arithmetic required by the GetDiskFreeSpace function.计算公式:
磁盘上剩余空间(字节)=磁道(Sector) * 剩余扇区 * 每扇区的字节数
例子:
DWORD sector,byte,cluster,free;
long int freespace,totalspace;
GetDiskFreeSpace("c://",§or,&byte,&free,&cluster);
totalspace=(cluster)*(byte)*(sector)/1024/1024;
freespace=(free)*(byte)*(sector)/1024/1024;
相关文章推荐
- 得到磁盘剩余空间
- VC 得到磁盘的空间(总的、已用的、剩余的)
- 调用API函数得到磁盘上剩余空间的值
- 得到SQLSERVER 2005 数据库的当前数据库中的数据文件所在磁盘的剩余空间
- 【磁盘处理相关方法】2,得到磁盘总空间、可用剩余空间
- linux查看磁盘剩余空间和文件大小
- 获取 iPhone 剩余磁盘空间的代码
- 获取磁盘类型及剩余空间 GetDiskFreeSpaceEx GetDriveTypeW GetVolumeInformation
- 磁盘有剩余空间,但是使用了是100%
- 根据文件路径获取剩余磁盘空间
- 在 Mac OS X Lion 中查看剩余磁盘空间最简单的方法
- 如何获取磁盘剩余空间(包括光驱中的光盘)
- [导入]用批处理写的显示磁盘剩余空间的小程序。
- 代码,显示IPhone剩余磁盘空间
- 获取磁盘剩余空间 Django项目几个主要文件功能的解释
- df 查看磁盘已使用多少空间、剩余多少空间、可用多少空间
- [测试]Linux操作系统查看磁盘剩余空间
- 利用剩余磁盘空间新建分区
- shell_检查磁盘剩余空间
- 检查磁盘剩余空间大小