add getConfig method
This commit is contained in:
parent
3037ef8b00
commit
de5e9861dd
|
@ -282,6 +282,14 @@ public class Service extends Win32Bindings implements java.io.Serializable
|
||||||
Service.throwLastErrorException();
|
Service.throwLastErrorException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceConfig getConfig() throws Win32Exception {
|
||||||
|
ServiceConfig config = new ServiceConfig();
|
||||||
|
if (!QueryServiceConfig(this.m_hService, config)) {
|
||||||
|
Service.throwLastErrorException();
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
private static final void throwLastErrorException()
|
private static final void throwLastErrorException()
|
||||||
throws Win32Exception
|
throws Win32Exception
|
||||||
{
|
{
|
||||||
|
@ -318,10 +326,18 @@ public class Service extends Win32Bindings implements java.io.Serializable
|
||||||
private static final native boolean StartService(long handle);
|
private static final native boolean StartService(long handle);
|
||||||
private static final native boolean StopService(long handle);
|
private static final native boolean StopService(long handle);
|
||||||
|
|
||||||
|
private static native boolean QueryServiceConfig(long handle,
|
||||||
|
ServiceConfig config);
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
List services = getServiceNames();
|
List services = getServiceNames();
|
||||||
for (int i=0; i<services.size(); i++) {
|
for (int i=0; i<services.size(); i++) {
|
||||||
System.out.println("'" + services.get(i) + "'");
|
String name = (String)services.get(i);
|
||||||
|
Service service = new Service(name);
|
||||||
|
ServiceConfig config = service.getConfig();
|
||||||
|
System.out.println("[" + name + "]" +
|
||||||
|
"=" +
|
||||||
|
"[" + config.getBinaryPathName() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue