Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    How can I get read information from my harddisk in QT

    General and Desktop
    2
    4
    1788
    Loading More Posts
    • 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
      yanyuyu001 last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • Y
          yanyuyu001 last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • First post
              Last post