Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Want to get drive detail with GetVolumeInformation.

Want to get drive detail with GetVolumeInformation.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivekmalik2466
    wrote on last edited by
    #1

    Want to get drive detail list of drives, total size, used space, free space ,drive is external ,hard disk.

    @
    QString TvInfo(QString & tdrive)
    {

    WCHAR szVolumeName[256] ;
    WCHAR szFileSystemName[256];
    DWORD dwSerialNumber = 0;
    DWORD dwMaxFileNameLength=256;
    DWORD dwFileSystemFlags=0;
    
    bool ret = false;
    qDebug()<<  "get bool return-----" <<GetVolumeInformation( (WCHAR *) tdrive.utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
    qDebug()<< "FileSystemName format type----"<<QString::fromUtf16 ( (const ushort *) szFileSystemName) ;
    qDebug()<< "VolumeName--------v"<<QString::fromUtf16 ( (const ushort *) szVolumeName).toAscii();
    qDebug()<< "SerialNumber"<<dwSerialNumber ;
    qDebug()<< "MaxFileNameLength"<<dwMaxFileNameLength ;
    
    qDebug()<< "FileSystemFlags"<< dwFileSystemFlags;
    

    qDebug()<< "hello "<< 256 ;
    if(!ret)return QString("");
    QString vName=QString::fromUtf16 ( (const ushort *) szVolumeName) ;
    vName.trimmed();
    return vName;
    }

    void Drive::GetDriveDetail()
    {
    qDebug()<<"all get drive here////////////////////////////////////////////////////";
    foreach( QFileInfo drive, QDir::drives() )
    {
    qDebug()<<"--------------------------------";
    QString tdrv=drive.absolutePath();
    bool tdrvisdirectory=drive.isDir();
    qDebug()<<"tdrvisdirectory---------"<<tdrvisdirectory;
    qDebug()<<"path----"<<tdrv ;
    QString volume_name = TvInfo(tdrv);
    qDebug()<<"volume name--------"<<volume_name;
    }
    }@

    my output is.
    @
    all get drive here////////////////////////////////////////////////////

    tdrvisdirectory--------- true
    path---- "C:/"
    get bool return----- 1
    FileSystemName format type---- "NTFS"
    VolumeName--------v ""
    SerialNumber 2551737821
    MaxFileNameLength 255
    FileSystemFlags 65470719
    hello 256
    volume name-------- ""

    tdrvisdirectory--------- true
    path---- "F:/"
    get bool return----- 1
    FileSystemName format type---- "NTFS"
    VolumeName--------v "New Volume"
    SerialNumber 208470474
    MaxFileNameLength 255
    FileSystemFlags 65470719
    hello 256
    volume name-------- ""
    @

    here i want list of drives, total size, used space, free space ,drive is external ,hard disk.but some thing are missing

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wilk
      wrote on last edited by
      #2

      Hello.
      I suggest you not to follow MS's ideology NIH and use Qt and Boost for your purposes:

      Get drive list with "QFSFileEngine::drives ()":http://doc.qt.nokia.com/4.7-snapshot/qfsfileengine.html#drives.

      Use Bost.FileSystem function "space":http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/reference.html#space to get information about drives.

      You may need a convertion from QString to std::basic_string<wchar_t> for Windows or std::basic_string<char> for other OS.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved