CString firstchar = strDestFileDirectory.Mid(0,1);
CString strRootPath=firstchar + L":\\";
DWORD dwSectorsPerCluster=0;//每簇中扇区数
DWORD dwBytesPerSector=0;//每扇区中字节数
DWORD dwFreeClusters=0;//剩余簇数
DWORD dwTotalClusters=0;//总簇数
if (GetDiskFreeSpace(strRootPath,&dwSectorsPerCluster,&dwBytesPerSector,
&dwFreeClusters,&dwTotalClusters))
{
//m_dwVolSize=dwTotalClusters*dwSectorsPerCluster*dwBytesPerSector;//不能这样,否则越界
double dd=dwSectorsPerCluster*dwBytesPerSector/(1024.*1024.);
dd=dd/1024.;
double m_dFree=dwFreeClusters*dd;//该磁盘剩余容量总大小
if (m_dFree < 1)
{
AfxMessageBox(_T("硬盘空间小于1G,请清理空间"));
}
}
MFC 获取盘符剩余容量
最新推荐文章于 2020-09-11 08:17:15 发布