C++ Builder disk info

poruka: 2
|
čitano: 847
|
moderatori: XXX-Man, vincimus
1
+/- sve poruke
ravni prikaz
starije poruke gore
15 godina
neaktivan
offline
C++ Builder disk info

Pozdrav, kako najlakse procitati informacije o disku u c++

(znaci izlistavanje svih particija, velicina, tip, slobodan prostor)?

 

Dali baš treba WIN32 API koristiti za to ili? :/

Poruka je uređivana zadnji put pon 10.9.2012 4:27 (NiGHT_RiDER92).
Moj PC  
0 0 hvala 0
14 godina
neaktivan
offline
Re: C++ Builder disk info

U oba slučaja dodati:

 

#include <IOUtils.hpp>

 

Za izlistavanje particija i provjeru njihovog tipa:

 

    System::DynamicArray<System::UnicodeString>lstDrives =
       TDirectory::GetLogicalDrives();

    for (int i = 0; i < lstDrives.Length; i++) {
       AnsiString strDrive = lstDrives[i];
       UINT drvType = GetDriveType(strDrive.c_str());

       if (drvType == DRIVE_NO_ROOT_DIR)
          ShowMessage(L"Drive: " + lstDrives[i] +
          L"\n" L"The root path is invalid; for example, "
          L"there is no volume is mounted at the path");
       else if (drvType == DRIVE_REMOVABLE)
          ShowMessage(L"Drive: " + lstDrives[i] +
          "\n" L"The drive has removable media (floppy drive or flash card reader)"
             );
       else if (drvType == DRIVE_FIXED)
          ShowMessage(L"Drive: " + lstDrives[i] +
          "\n" L"The drive has fixed media (drive, flash drive, or thumb drive)"
             );
       else if (drvType == DRIVE_REMOTE)
          ShowMessage(L"Drive: " + lstDrives[i] +
          "\n" L"The drive is a remote (network) drive");
       else if (drvType == DRIVE_CDROM)
          ShowMessage(L"Drive: " + lstDrives[i] +
          "\n" L"The drive is a CD-ROM drive or a DVD drive");
       else if (drvType == DRIVE_RAMDISK)
          ShowMessage(L"Drive: " + lstDrives[i] +
          "\n" L"The drive is a RAM disk");
       else // if( drvType == DRIVE_UNKNOWN )
             ShowMessage(L"The drive type cannot be determined");
    }

 

Za provjeru veličine diska, slobodnog prostora (postavi tri labele na formu):

 

    DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters;
    __int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;

    ::GetDiskFreeSpaceEx("C:\\", (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
    Label1->Caption = "Avaliable disk space (for this user): " + AnsiString(i64FreeBytesToCaller/1024/1024 ) + " MB";
    Label2->Caption = "Total disk space: " + AnsiString(i64TotalBytes /1024/1024 ) + " MB";
    Label3->Caption = "Free disk space: " + AnsiString(i64FreeBytes /1024/1024) + " MB";

 

Kada lajavci laju onda završe ovako: http://i471.photobucket.com/albums/rr77/toropreto/2012-07-0813_30_07.gif
Poruka je uređivana zadnji put pon 10.9.2012 9:41 (TracerCPP).
1
Nova poruka
E-mail:
Lozinka:
 
vrh stranice