Click here to Skip to main content
13,202,262 members (57,298 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked
Posted 8 Apr 2009

GetFinalPathNameByHandle API Hangs

, 8 Apr 2009
Rate this:
Please Sign up or sign in to vote.
GetFinalPathNameByHandle is an new API introduced in Windows Vista. We will look at how to resolve an issue related to its usage.

GetFinalPathNameByHandle is a new API introduced in Windows Vista. As you can read from MSDN, the purpose of this API is to return the file name corresponding to a file handle.

Some months back, I wrote a small utility, OpenedFileFinder, which lists all the files that are opened under a certain folder. While writing this application, the main problem I came across was to get the file name from the handle. Initially, I used a function called NtQueryObject(). But the problem with this API is that if we try to query the details for a certain object such as a pipe, directory handle etc., it will hang. So, in my application, I introduced a driver to get around this hanging problem. When I found the new GetFinalPathNameByHandle(), I was so happy and I thought at least I could avoid the driver in Vista. I tried the API, but came to find that this API also has the same problem described earlier.

It seems the GetFinalPathNameByHandle also uses the same NtQueryObject() to get the file name and so it hangs. Any how, I reported this bug to Microsoft Connect. Let us see how they solve the problem.

Another API that is worth mentioning here is GetFileInformationByHandleEx(), which is also a new API introduced in Vista. Using this API, I can get the file name from a handle. So I decided to check whether the same problem exists in this API. Surprisingly, it worked fine. And in MSDN, it is mentioned that it uses a driver for attaining the task. So I highly recommend using the GetFileInformationByHandleEx() API instead of GetFinalPathNameByHandle().


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
Singapore Singapore
No Biography provided

You may also be interested in...

Comments and Discussions

AnswerVery poor Pin
Elmue11-Sep-13 5:29
memberElmue11-Sep-13 5:29 
GeneralRe: Very poor Pin
Naveen29-Oct-13 23:39
memberNaveen29-Oct-13 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 8 Apr 2009
Article Copyright 2009 by Naveen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid