Want to get drive detail with GetVolumeInformation.
-
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
-
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.