ProcessQuery to get pid from windows service name

This commit is contained in:
Doug MacEachern 2004-08-13 01:24:11 +00:00
parent bd8ecac6c5
commit 4defcaae4c
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
package net.hyperic.sigar.ptql;
import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarProxy;
import net.hyperic.sigar.SigarException;
public class WindowsServiceQuery implements ProcessQuery {
private String name;
public static native long getServicePid(String name);
public WindowsServiceQuery(String name) {
this.name = name;
}
public boolean match(SigarProxy sigar, long pid)
throws SigarException {
return pid == getServicePid(this.name);
}
public static void main(String[] args) throws Exception {
Sigar sigar = new Sigar(); //load the .dll
System.out.println(getServicePid(args[0]));
}
}