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 844 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.
  • CybeXC Offline
    CybeXC Offline
    CybeX
    wrote on 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)?

    JKSHJ aha_1980A 2 Replies Last reply
    0
    • CybeXC CybeX

      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)?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on 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
      • CybeXC CybeX

        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)?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 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

        • Login

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