磁盘容量(GetDiskFreeSpace函数和GetDiskFreeSpaceEx函数)
来源:互联网 发布:知乎怎么刷新 编辑:程序博客网 时间:2024/06/17 02:27
GetDiskFreeSpace函数和GetDiskFreeSpaceEx函数,主要是用来计算磁盘的各种容量,具体能计算什么,代码中注释得很详细
<pre name="code" class="cpp">#include <Windows.h>#include <iostream>using namespace std;int main(){ //得出磁盘的可用空间 DWORD dwTotalClusters;//总的簇 DWORD dwFreeClusters;//可用的簇 DWORD dwSectPerClust;//每个簇有多少个扇区 DWORD dwBytesPerSect;//每个扇区有多少个字节 BOOL bResult = GetDiskFreeSpace(TEXT("C:"),&dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters); if(bResult){ cout << "使用GetDiskFreeSpace函数获取磁盘空间信息" << endl; cout << "总簇数量: " << dwTotalClusters << endl; cout << "可用的簇: " << dwFreeClusters << endl; cout << "每个簇有多少个扇区: " << dwSectPerClust << endl; cout << "每个扇区有多少个字节: " << dwBytesPerSect << endl; cout << "磁盘总容量: " << dwTotalClusters * (DWORD64)dwSectPerClust * (DWORD64)dwBytesPerSect << endl; cout << "磁盘空闲容量: " << dwFreeClusters * (DWORD64)dwSectPerClust * (DWORD64)dwBytesPerSect << endl; } cout << "\n\n" << endl; DWORD64 qwFreeBytes, qwFreeBytesToCaller, qwTotalBytes; bResult = GetDiskFreeSpaceEx(TEXT("C:"), (PULARGE_INTEGER)&qwFreeBytesToCaller, (PULARGE_INTEGER)&qwTotalBytes, (PULARGE_INTEGER)&qwFreeBytes); if(bResult){ cout << "使用GetDiskFreeSpaceEx函数获取磁盘空间信息" << endl; cout << "磁盘总容量: " << qwTotalBytes << endl; cout << "可用的磁盘空闲容量: " << qwFreeBytes << endl; cout << "磁盘空闲容量: " << qwFreeBytesToCaller << endl; } system("pause");}
运行结果
0 0
- 磁盘容量(GetDiskFreeSpace函数和GetDiskFreeSpaceEx函数)
- GetDiskFreeSpaceEx函数
- GetDiskFreeSpaceEx函数
- GetDiskFreeSpaceEx 函数介绍
- 如何用GetDiskFreeSpace函数?此函数有什么限制吗?
- 获得磁盘剩余空间:GetDiskFreeSpaceEx
- Windows API一日一练(62)GetDiskFreeSpaceEx函数
- GetDiskFreeSpaceEx()
- StringBuffer中的容量函数
- statfs函数获取大容量磁盘信息速度慢的解决过程
- statfs函数获取大容量磁盘信息速度慢的解决过程
- statfs函数获取大容量磁盘信息速度慢的解决过程
- C#获取磁盘总容量和剩余容量
- C#获取磁盘总容量和剩余容量
- 【ASM】查看ASM磁盘组剩余容量和总容量
- 获取磁盘类型及剩余空间 GetDiskFreeSpaceEx GetDriveTypeW GetVolumeInformation
- 统计大容量文本里面单词的函数(方法)
- Qt中获得磁盘容量和剩余磁盘空间(Windows平台)
- C#学习之类
- android studio解决warning: Ignoring InnerClasses attribute for an anonymous inner class
- idea发布JavaEE项目到tomcat需要的配置
- IBMER'S INFOMATION之Salesforce
- pdf.js 框架使用方法
- 磁盘容量(GetDiskFreeSpace函数和GetDiskFreeSpaceEx函数)
- 协程(三)协程与Continuation
- iOS应用架构谈 本地持久化方案及动态部署
- React--组件生命周期
- 单向链表的实现
- 【Sql语句】自己摸索出得比较复杂的一个查询语句
- 信公号刷量工具昨崩溃 大V“裸泳”阅读量打回原形
- slf4j使用
- mysql 5.7 zip版配置安装