且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Java代码获取当前正在运行的应用程序名称?

更新时间:2023-10-20 15:27:40

我不确定Java是否具有可以为您完成此操作的类,因此您需要尝试以下三种方法之一: br/>
1.使用Windows tasklist程序获取列表并将其输出通过管道传输到Java应用程序中.

2.使用 Java Native Access [ ^ ]库连接到Windows ^ ]函数以获取详细信息.

3.编写一个C ++库以获取所需的详细信息(从EnumProcesses获取)并通过JNI访问它.
I am not sure that Java has a class that will do this for you so you would need to try one of three options:

1. Use the Windows tasklist program to get the list and pipe its output into your Java app.

2. Use the Java Native Access[^] library to interface to the Windows EnumProcesses[^] function to get the details.

3. Write a C++ library to get the details you want (from EnumProcesses) and access it via JNI.