![](/img/trans.png)
[英]VMWare Virtualized Applications and its Running Process instructions Tracing
[英]Get process ID by part of its process name at Sigar
我正在使用Sigar库来获取进程ID并对其进行监视。
我有一个进程,可以根据运行该进程的应用程序的版本来更改名称。 例如:
是否可以使用myProcess%
通过指定诸如myProcess%
类的方法来获取进程ID?
现在我正在使用这个:
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$);
Exe.Name
返回正在运行的进程的路径,而不仅仅是进程的名称。
因此,您的正则表达式应如下所示:
long[] pids = this.find.find("Exe.Name.re=^.*\\\\Photo(.)*.exe$");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.