1

I am using JNA with Java to find some properties about open windows on a Windows machine desktop. I am trying to find a way to get the file being accessed by an arbitrary windowed application. For instance, say I get information regarding the window of an open pdf document in adobe. I want to be able to get the filepath of the pdf document displayed in the window.

I know about the GetWindowModuleFileName() method, however this gets you the filepath of the executable of the application, i.e. 'javaw.exe'. If you have 'my.pdf' open in adobe, I'd like to get the filepath of this document, i.e. 'C:\...\my.pdf'.

I've done some searching around (on this site and others) and haven't found anything yet on this in particular.

thank you for your time, -Kevin

1 Answer 1

0

If you know the process ID, you can get the list of all files currently opened by the process using Handle utility. However, it depends if adobe reader continues to keep the file open or closes it after reading it completely.

2
  • Thank you for your answer, I am finding the utility very useful. After a few days of experimenting and looking around I have a quick follow up question. With the PID, you can get a full list of the files being accessed, 'handle -p PID'. Is it possible to isolate the file opened in programs such as adobe or word, etc i.e. 'my.pdf, my.docx' from all of the other ones listed by the utility? I'm trying to write a program that uses this information, so I'm looking for a way to isolate this filepath.
    – kevin
    Jan 4, 2012 at 19:45
  • @kevin: I think you need to parse the output of handle utility and extract the information you require.
    – Gowtham
    Jan 5, 2012 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.