set ServiceConfig.exe in jni

This commit is contained in:
Doug MacEachern 2008-03-27 00:55:40 +00:00
parent 5f0f5db9ed
commit 4d960ecb0b
2 changed files with 10 additions and 7 deletions

View File

@ -300,6 +300,7 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_QueryServiceConfig)
(JNIEnv *env, jclass, jlong handle, jobject obj) (JNIEnv *env, jclass, jlong handle, jobject obj)
{ {
char buffer[8192]; /* 8k is max size from mdsn docs */ char buffer[8192]; /* 8k is max size from mdsn docs */
char exe[SIGAR_CMDLINE_MAX], *ptr;
LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)buffer; LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)buffer;
DWORD bytes; DWORD bytes;
jfieldID id; jfieldID id;
@ -322,6 +323,13 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_QueryServiceConfig)
SERVICE_SetStringField("path", config->lpBinaryPathName); 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_SetStringField("loadOrderGroup", config->lpLoadOrderGroup);
SERVICE_SetIntField("tagId", config->dwTagId); SERVICE_SetIntField("tagId", config->dwTagId);

View File

@ -107,6 +107,7 @@ public class ServiceConfig {
int startType; int startType;
int errorControl; int errorControl;
String path; String path;
String exe;
String loadOrderGroup; String loadOrderGroup;
int tagId; int tagId;
String[] dependencies; String[] dependencies;
@ -151,13 +152,7 @@ public class ServiceConfig {
} }
public String getExe() { public String getExe() {
String[] args = getArgv(); return this.exe;
if (args.length == 0) {
return null;
}
else {
return args[0];
}
} }
/** /**