Get FileDescription (ProgramName) from .exe

不羁的心 提交于 2019-12-05 02:30:26

问题


I am developing an activity tracker for my development work in Eclipse (with Java). I now have the program's path and the duration i spent in it.

e.g.: 7min C:\Program Files (x86)\Internet Explorer\iexplore.exe and 10min C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE

I now want to know the name of the program. In C# I get it like this:

System.Diagnostics.FileVersionInfo versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(file);
return (versionInfo.FileDescription == string.Empty) ? null : versionInfo.FileDescription;

Unfortunately, I found no such way in Java and i am not sure if this is even possible?

Thank you!

Edit: I also read this post and the accepted answer but was unable to get the FileDescription...


回答1:


I am not aware of such API in Java. However, what you can do is as follows:

  1. Create a C# project with the required method that returns program name.
  2. Export this project to DLL.
  3. In your java code you can use JNI to call the native code from you DLL project. You can check these examples: SUN JNI Example , Making Native Windows API calls from within a Java Application

(I would suggest you to consider whether you absolutely need this description.) Good luck!



来源:https://stackoverflow.com/questions/12347215/get-filedescription-programname-from-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!