从.exe获取FileDescription(ProgramName) [英] Get FileDescription (ProgramName) from .exe

查看:89
本文介绍了从.exe获取FileDescription(ProgramName)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我在Eclipse(使用Java)中的开发工作开发活动跟踪器.现在,我有了程序的路径以及在其中花费的时间.

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.

例如:7min C:\Program Files (x86)\Internet Explorer\iexplore.exe10min C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE

我现在想知道程序的名称.在C#中我是这样的:

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;

不幸的是,我在Java中找不到这种方法,而且我不确定这是否可能?

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

谢谢!

编辑:我还阅读了此发布和可接受的答案,但无法获取FileDescription ...

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

推荐答案

我不知道Java中的此类API.但是,您可以执行以下操作:

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

  1. 使用返回程序名的必需方法创建一个C#项目.
  2. 将此项目导出到DLL.
  3. 在您的Java代码中,您可以使用JNI从您的DLL项目中调用本机代码.您可以检查以下示例: SUN JNI示例从Java应用程序内部进行本机Windows API调用
  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!

这篇关于从.exe获取FileDescription(ProgramName)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆