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. How can I get read information from my harddisk in QT
Forum Updated to NodeBB v4.3 + New Features

How can I get read information from my harddisk in QT

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k 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.
  • Y Offline
    Y Offline
    yanyuyu001
    wrote on last edited by
    #1

    I didn't find any api in QT to read information from my harddisk,so I use windows api GetVolumeInformation.but it return false.get the harddisk information failed.Following codes is how I use the api.
    @LPCTSTR lpRootPathName = L"c:\";
    LPWSTR volumeNameBuffer;
    DWORD nVolumeNameSize = 12;
    DWORD VolumeSerialNumber;
    DWORD MaximumComponentLength;
    LPWSTR fileSystemNameBuffer;
    DWORD nFileSystemNameSize = 10;
    DWORD FileSystemFlags;
    if(!GetVolumeInformation(lpRootPathName,
    volumeNameBuffer, nVolumeNameSize,
    &VolumeSerialNumber, &MaximumComponentLength,
    &FileSystemFlags,
    fileSystemNameBuffer, nFileSystemNameSize))
    return false;@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      depending on your version of Qt you could use QSystemStorage from QtMobility.

      Anyway nVolumeNameSize and nFileSystemNameSize are looking arbitrary short. A better place for Windows API question is the MSDN forum

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yanyuyu001
        wrote on last edited by
        #3

        I find the problem.I rewrite the code as:
        @
        LPCTSTR lpRootPathName = L"c:\"; // 取C盘
        LPTSTR volumeNameBuffer = new TCHAR[12]; // 磁盘卷标
        DWORD nVolumeNameSize = 12; // 卷标的字符串长度
        DWORD VolumeSerialNumber; // 硬盘序列号
        DWORD MaximumComponentLength; // 最大的文件长度
        LPTSTR fileSystemNameBuffer = new TCHAR[10]; // 存储所在盘符的分区类型的长指针变量
        DWORD nFileSystemNameSize = 10; // 分区类型的长指针变量所指向的字符串长度
        DWORD FileSystemFlags; // 文件系统的一此标志
        @
        I return what I want.But I don't know why.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you should re-read the documentation of "GetVolumeInformation":http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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