</pre><pre name="code" class="cpp">#include <Windows.h>
#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "chs");
BOOL bResult;
DWORD64 qwFreeBytesAvailable, qwTotalNumberOfBytes, qwTotalNumberOfFreeBytes;
bResult = GetDiskFreeSpaceEx(L"C:/",
(PULARGE_INTEGER)&qwFreeBytesAvailable,
(PULARGE_INTEGER)&qwTotalNumberOfBytes,
(PULARGE_INTEGER)&qwTotalNumberOfFreeBytes);
if (bResult) {
cout<<"\n ==== 盘空间信息 ==== \n"<<endl;
printf("磁盘分区总容量:%.2f GB\n", (double)(qwTotalNumberOfBytes /(1024*1024*1024)));
printf ("可获得的空闲空间:%.2f GB\n", (double)qwFreeBytesAvailable /(1024*1024*1024));
printf ("总的空闲空间:%.2f GB\n", (double)qwTotalNumberOfFreeBytes /(1024*1024*1024));
printf("磁盘分区总容量:%.2f MB\n", (double)(qwTotalNumberOfBytes /(1024*1024)));
printf ("可获得的空闲空间:%.2f MB\n", (double)qwFreeBytesAvailable /(1024*1024));
printf ("总的空闲空间:%.2f MB\n", (double)qwTotalNumberOfFreeBytes /(1024*1024));
}
getchar();
return 0;
}
显示C磁盘空间
最新推荐文章于 2024-08-13 21:30:45 发布