获取系统的各个分区

来源:互联网 发布:澳洲阳光海岸大学 知乎 编辑:程序博客网 时间:2024/06/13 10:59

获取系统的分区情况;   

TCHAR buf[100];
 DWORD len = GetLogicalDriveStringsW(sizeof(buf),buf);
 CString message;
 for(TCHAR* s=buf ; *s ; s+=_tcslen(s)+1)
 {
  LPCTSTR nDeviceinfo = s;
  UINT   uDriveType   =   GetDriveType(nDeviceinfo);

  if   (uDriveType  &  DRIVE_FIXED)   {
   ULARGE_INTEGER FreeAv,TotalBytes,FreeBytes;
   if(GetDiskFreeSpaceEx(nDeviceinfo,&FreeAv,&TotalBytes,&FreeBytes))
   {
    //格式化信息,并显示出来
    CString strTotalBytes,strFreeBytes;
    //strTotalBytes.Format(_T("%uMB"),TotalBytes.QuadPart/1024/1024);
    //strFreeBytes.Format(_T("%uMB"),FreeBytes.QuadPart/1024/1024);
    /*int nItem=m_listDisk.InsertItem(0,L"0");*/
    m_combo_record_dir.InsertString(m_combo_record_dir.GetCount(),nDeviceinfo);
    //m_listDisk.SetItemText(nItem,1,strFreeBytes);
    //m_listDisk.SetItemText(nItem,2,strTotalBytes);
   }
  }
 }

0 0
原创粉丝点击