From 4defcaae4c53a3c3fb9c12eb37ec1a38026d0753 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 13 Aug 2004 01:24:11 +0000 Subject: [PATCH] ProcessQuery to get pid from windows service name --- .../sigar/ptql/WindowsServiceQuery.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bindings/java/src/net/hyperic/sigar/ptql/WindowsServiceQuery.java diff --git a/bindings/java/src/net/hyperic/sigar/ptql/WindowsServiceQuery.java b/bindings/java/src/net/hyperic/sigar/ptql/WindowsServiceQuery.java new file mode 100644 index 00000000..b2909569 --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/ptql/WindowsServiceQuery.java @@ -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])); + } +}