PDA

View Full Version : C++/Qt5/Windows 7 - Trying to get drive information?



jimbo
18th November 2015, 18:55
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

void pisd::getDriveInfo() {
QString driveInfo, drive;
QStringList driveData;

foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
if (storage.isValid()) {
driveInfo = storage.rootPath();
driveInfo.append(storage.displayName());
driveInfo.append(" - ");
driveInfo.append(QString::number(((float)storage.b ytesTotal() / 1024 / 1024 / 1024),'f' ,2));
driveInfo.append(" GB");
driveInfo.append(" - ");
driveInfo.append(driveType());
driveData.append(driveInfo);
}
}
qDebug() << driveData;
}
Output
("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")
Output, no floppy, no SD card no CD/DVD.
("A:/A:/ - 0.00 GB - 3", "C:/Main - 100.00 GB - 3", ......, "Z:/Z:/ - 0.00 GB - 3")

anda_skoa
18th November 2015, 20:18
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,
_

ChrisW67
18th November 2015, 20:19
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.

jimbo
18th November 2015, 22:12
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
("A:/ TEST - 1423.50 KB - FAT", "C:/Main - 100.00 GB - NTFS", ...... , "Z:/ No media present")