2009년 9월 21일 월요일

하드 디스크 용량 체크(GB소수점 이하 까지 가능)

 

출처 : http://blog.naver.com/PostView.nhn?blogId=higil&logNo=14056226&widgetTypeCall=true

CString str;
float TotalBytes, fTotal, FreeBytes, fAvail, fUsed;

ULARGE_INTEGER uliUserFree, uliTotal, uliRealFree;
CString strDirectoryName="d:\\";                                  // 알고자하는 디스크이름

if(GetDiskFreeSpaceEx(strDirectoryName, &uliUserFree, &uliTotal, &uliRealFree))
{
        TotalBytes =uliTotal.LowPart+(double)uliTotal.HighPart*(double)4294967296;
        fTotal = (float)(TotalBytes/1024/1024/1024); // Convert (GB)    
        FreeBytes = uliRealFree.LowPart+(double)uliRealFree.HighPart*(double)4294967296;
        fAvail = (float)(FreeBytes/1024/1024/1024); // Convert (GB)
        fUsed = fTotal - fAvail;
  str.Format("D:\ Total %.1fGB, Free %.1fGB, Used %.1fGB", fTotal, fAvail, fUsed);
  MessageBox(str);
   }

댓글 없음: