zoukankan      html  css  js  c++  java
  • vc 查看硬盘盘符剩余空间

    string strtemp = "c:\123\456\789.txt";
    	char uuu[2] = {0};
    	uuu [0]= strtemp[0];
    	CString firstchar = uuu;
    	CString strRootPath=firstchar + ":\";
    	/*CString strRootPath="E:\123.txt";*///带根目录标记的磁盘符号
    	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)
    		{
    			WriteToLogAndTime("硬盘空间小于1G,请清理空间");
    			AfxMessageBox("硬盘空间小于1G,请清理空间");
    		}
    	}

    m_dFree是此文件所在盘符的剩余空间

  • 相关阅读:
    排序算法
    顺序表与链表
    二叉树
    查找算法
    15 Django 离线脚本
    poj 1330 Nearest Common Ancestors(LCA 基于二分搜索+st&rmq的LCA)
    hdu 6158 The Designer( 反演圆)
    圆的反演性质
    HDU 6153 A Secret(扩展kmp)
    kmp&扩展kmp
  • 原文地址:https://www.cnblogs.com/bbsno1/p/3262755.html
Copyright © 2011-2022 走看看