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. Get file path in Qt from winapi file HANDLE as QString, QFileInfo or something similiar

Get file path in Qt from winapi file HANDLE as QString, QFileInfo or something similiar

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5qt5.13.1winapihandles
3 Posts 3 Posters 850 Views
  • 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.
  • C Offline
    C Offline
    CybeX
    wrote on 18 Aug 2020, 11:14 last edited by
    #1

    My application makes use of CopyFileExW for fast copying, and includes the LPPROGRESS_ROUTINE callback to track progress. Since I can copy files simultaneously, I need to keep track of file progress in a global sense.

    To do this, I would use a QMap<QString, quint64> as a map of filepath / file hash and written bytes per file. In order to get the file path or file hash, I need to get the file path. One suggestion is to use GetFinalPathNameByHandleA which looks promising.

    Problem:

    It appears I do not have access to the GetFinalPathNameByHandleA function found in <fileapi.h> as seen in the image below:

    enter image description here

    How can I get a file path from a file HANDLE (in Windows spedcifically)?

    J A 2 Replies Last reply 18 Aug 2020, 11:20
    0
    • C CybeX
      18 Aug 2020, 11:14

      My application makes use of CopyFileExW for fast copying, and includes the LPPROGRESS_ROUTINE callback to track progress. Since I can copy files simultaneously, I need to keep track of file progress in a global sense.

      To do this, I would use a QMap<QString, quint64> as a map of filepath / file hash and written bytes per file. In order to get the file path or file hash, I need to get the file path. One suggestion is to use GetFinalPathNameByHandleA which looks promising.

      Problem:

      It appears I do not have access to the GetFinalPathNameByHandleA function found in <fileapi.h> as seen in the image below:

      enter image description here

      How can I get a file path from a file HANDLE (in Windows spedcifically)?

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 18 Aug 2020, 11:20 last edited by
      #2

      @CybeX said in Get file path in Qt from winapi file HANDLE as QString, QFileInfo or something similiar:

      It appears I do not have access to the GetFinalPathNameByHandleA function found in <fileapi.h> as seen in the image below:

      According to your screenshot, #if _WIN32_WINNT >= 0x0600 returned false. That's why the section is disabled.

      You need to #include the header that defines _WIN32_WINNT (Google should show you the way)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      5
      • C CybeX
        18 Aug 2020, 11:14

        My application makes use of CopyFileExW for fast copying, and includes the LPPROGRESS_ROUTINE callback to track progress. Since I can copy files simultaneously, I need to keep track of file progress in a global sense.

        To do this, I would use a QMap<QString, quint64> as a map of filepath / file hash and written bytes per file. In order to get the file path or file hash, I need to get the file path. One suggestion is to use GetFinalPathNameByHandleA which looks promising.

        Problem:

        It appears I do not have access to the GetFinalPathNameByHandleA function found in <fileapi.h> as seen in the image below:

        enter image description here

        How can I get a file path from a file HANDLE (in Windows spedcifically)?

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 18 Aug 2020, 11:24 last edited by
        #3

        Hi @CybeX,

        and to add to @JKSH: you probably want to use GetFinalPathNameByHandleW as this is the UNICODE version.

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        6

        2/3

        18 Aug 2020, 11:20

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved