0

我正在使用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$);
4

1 回答 1

0

Exe.Name返回运行进程的路径,而不仅仅是进程的名称。

因此,您的正则表达式应如下所示:

long[] pids = this.find.find("Exe.Name.re=^.*\\\\Photo(.)*.exe$");
于 2014-06-16T08:53:00.033 回答