简体   繁体   English

使用Java的JNA获取窗口正在访问的文件的文件路径

[英]Get the filepath of the file being accessed by a window using JNA with Java

I am using JNA with Java to find some properties about open windows on a Windows machine desktop. 我将JNA与Java结合使用,以找到有关Windows计算机桌面上打开的窗口的一些属性。 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. 例如,假设我获得有关Adobe中打开的pdf文档的窗口的信息。 I want to be able to get the filepath of the pdf document displayed in the window. 我希望能够获取显示在窗口中的pdf文档的文件路径。

I know about the GetWindowModuleFileName() method, however this gets you the filepath of the executable of the application, ie 'javaw.exe'. 我知道GetWindowModuleFileName()方法,但是这会为您提供应用程序可执行文件的文件路径,即“ javaw.exe”。 If you have 'my.pdf' open in adobe, I'd like to get the filepath of this document, ie 'C:\\...\\my.pdf'. 如果您在Adobe中打开了“ my.pdf”,我想获取此文档的文件路径,即“ 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 谢谢您的时间,-Kevin

If you know the process ID, you can get the list of all files currently opened by the process using Handle utility. 如果知道进程ID,则可以使用Handle实用程序获取该进程当前打开的所有文件的列表。 However, it depends if adobe reader continues to keep the file open or closes it after reading it completely. 但是,这取决于Adobe Reader是否继续打开文件或在完全读取文件后将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM