From 4d960ecb0bbd7d91447f54f3dbfe9e7edd25f07f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 27 Mar 2008 00:55:40 +0000 Subject: [PATCH] set ServiceConfig.exe in jni --- bindings/java/src/jni/win32/service.cpp | 8 ++++++++ .../java/src/org/hyperic/sigar/win32/ServiceConfig.java | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bindings/java/src/jni/win32/service.cpp b/bindings/java/src/jni/win32/service.cpp index 96d7d93e..91e01011 100644 --- a/bindings/java/src/jni/win32/service.cpp +++ b/bindings/java/src/jni/win32/service.cpp @@ -300,6 +300,7 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_QueryServiceConfig) (JNIEnv *env, jclass, jlong handle, jobject obj) { char buffer[8192]; /* 8k is max size from mdsn docs */ + char exe[SIGAR_CMDLINE_MAX], *ptr; LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)buffer; DWORD bytes; jfieldID id; @@ -322,6 +323,13 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_QueryServiceConfig) SERVICE_SetStringField("path", config->lpBinaryPathName); + SIGAR_W2A(config->lpBinaryPathName, exe, sizeof(exe)); + ptr = sigar_service_exe_get(NULL, exe, 0); + + env->SetObjectField(obj, + env->GetFieldID(cls, "exe", STRING_SIG), + env->NewStringUTF(ptr)); + SERVICE_SetStringField("loadOrderGroup", config->lpLoadOrderGroup); SERVICE_SetIntField("tagId", config->dwTagId); diff --git a/bindings/java/src/org/hyperic/sigar/win32/ServiceConfig.java b/bindings/java/src/org/hyperic/sigar/win32/ServiceConfig.java index b076bfac..1e7cb010 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/ServiceConfig.java +++ b/bindings/java/src/org/hyperic/sigar/win32/ServiceConfig.java @@ -107,6 +107,7 @@ public class ServiceConfig { int startType; int errorControl; String path; + String exe; String loadOrderGroup; int tagId; String[] dependencies; @@ -151,13 +152,7 @@ public class ServiceConfig { } public String getExe() { - String[] args = getArgv(); - if (args.length == 0) { - return null; - } - else { - return args[0]; - } + return this.exe; } /**