Created
June 19, 2013 16:03
-
-
Save a-andreyev/5815525 to your computer and use it in GitHub Desktop.
My qt5-qtsystems QStorageInfoPrivate::uriForDrive for Windows OSes realization to get uri-for-drive value similar with unix OSes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My qt5-qtsystems QStorageInfoPrivate::uriForDrive for Windows OSes realization to get uri-for-drive value similar with unix OSes | |
// yetanotherandreyev at gmail | |
QString QStorageInfoPrivate::uriForDrive(const QString &drive) | |
{ | |
WCHAR VolumeNameBuffer[100], FileSystemNameBuffer[100]; // not sure about buffer size yet | |
long unsigned int sn; | |
if (GetVolumeInformation((WCHAR *)drive.utf16(), VolumeNameBuffer, 100, &sn, NULL, NULL, FileSystemNameBuffer, 100)) { | |
QString uri = QString::number(sn,16).toUpper(); | |
int x = uri.size(); | |
if (x<8) { | |
for (int i=0;i<(8-x);i++) { | |
uri.insert(0,QString("0")); | |
} | |
} | |
if (uri.size()==8) uri.insert(4,QString("-")); | |
return uri; | |
} | |
return QString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment