我正在使用Sigar 库来获取进程 ID 并对其进行监视。
我有一个进程可以根据运行该进程的应用程序版本更改名称。例如:
- myProcess64.exe
- myProcess65.exe
有没有办法使用 Sigar 通过指定类似的东西来获取进程 ID myProcess%
?
现在我正在使用这个:
ProcessFinder find = new ProcessFinder(this.sigar);
long[] pids = find.find("Exe.Name.ct=" + this.processName);
我一直在尝试通过使用PTQL(进程表查询语言)语法来使用正则表达式,但没有成功:
//getting the process with name "Photoshop.exe" (not working currently)
long[] pids = find.find("Exe.Name.re=^Photo(.)*.exe$);