Results 1 to 4 of 4

Thread: C++/Qt5/Windows 7 - Trying to get drive information?

  1. #1
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default C++/Qt5/Windows 7 - Trying to get drive information?

    Qt5.5
    Qt Creator 3.5.1
    Windows 7
    C++

    Hello,

    I'm trying to get drive information (ie. floppy, sd card, usb memory stick, cd/dvd drive).
    This is the output I get at the moment (A is a floppy, C is an HDD, S is an SD card, Z is a CD/DVD drive)
    All drives are showing as type 3 (Fixed).
    What should I be looking at to get whether the device is an sd card, cd/dvd drive or removable drive, or even how its fornatted?
    Thanks in advance for any help.

    If this can be done? I would like to know if the inserted drive media is linux - EXT3/4.

    Regards
    Qt Code:
    1. void pisd::getDriveInfo() {
    2. QString driveInfo, drive;
    3. QStringList driveData;
    4.  
    5. foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
    6. if (storage.isValid()) {
    7. driveInfo = storage.rootPath();
    8. driveInfo.append(storage.displayName());
    9. driveInfo.append(" - ");
    10. driveInfo.append(QString::number(((float)storage.bytesTotal() / 1024 / 1024 / 1024),'f' ,2));
    11. driveInfo.append(" GB");
    12. driveInfo.append(" - ");
    13. driveInfo.append(driveType());
    14. driveData.append(driveInfo);
    15. }
    16. }
    17. qDebug() << driveData;
    18. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. Output
    2. ("A:/TEST - 0.00 GB - 3", "C:/Main - 100.00 GB - 3", ...... , "S:/boot - 0.05 GB - 3", ...... , "Z:/GParted-live - 0.19 GB - 3")
    3. Output, no floppy, no SD card no CD/DVD.
    4. ("A:/A:/ - 0.00 GB - 3", "C:/Main - 100.00 GB - 3", ......, "Z:/Z:/ - 0.00 GB - 3")
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: C++/Qt5/Windows 7 - Trying to get drive information?

    Have you checked QStorageInfo::fileSystemType()?

    But I would be surprised if Windows even knew about Ext3/4. I certainly can't handle it without additional software/drivers.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: C++/Qt5/Windows 7 - Trying to get drive information?

    If your driveType() function always returns '3' then perhaps you should be sharing it. We cannot see it so cannot offer any specific advice. The Qt portable storage info wrappers do not expose media type AFAICT. You will likely have to rely on Windows API calls to do this.

    The Windows API will not be able to do anything with an Ext2/3/4 disk other than probably identify it as empty or corrupt. By extension, the Qt wrappers on Windows will likely not report foreign disks.

  4. #4
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: C++/Qt5/Windows 7 - Trying to get drive information?

    Hello anda_skoa and ChrisW67,

    Thanks for your replies.
    QStorageInfo::fileSystemType()
    Is just the job.

    I understand that Windows refuses to acknowledge linux file systems even exist.
    I will keep searching for some software that will allow me to access EXT2/3/4 file systems.
    Doing it myself is a no go.

    Regards
    Qt Code:
    1. ("A:/ TEST - 1423.50 KB - FAT", "C:/Main - 100.00 GB - NTFS", ...... , "Z:/ No media present")
    To copy to clipboard, switch view to plain text mode 
    Last edited by jimbo; 18th November 2015 at 22:21.

Similar Threads

  1. Replies: 1
    Last Post: 20th July 2015, 20:37
  2. Displaying information in various windows
    By GAURAV PANT in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2014, 02:21
  3. Replies: 2
    Last Post: 9th October 2010, 08:38
  4. Retrieving windows Drive labels
    By Baasie in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2009, 08:05
  5. How to get System Information(Windows)
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 13:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.