add PdhLookupPerfIndexByName wrapper

This commit is contained in:
Doug MacEachern 2007-03-04 19:06:53 +00:00
parent a4f7770067
commit 9289f45dce
2 changed files with 22 additions and 0 deletions

View File

@ -430,6 +430,26 @@ JNIEXPORT jstring SIGAR_JNI(win32_Pdh_pdhLookupPerfName)
} }
} }
JNIEXPORT jint SIGAR_JNI(win32_Pdh_pdhLookupPerfIndex)
(JNIEnv *env, jclass cur, jstring jname)
{
DWORD index;
LPCTSTR name =
JENV->GetStringChars(env, jname, NULL);
PDH_STATUS status =
PdhLookupPerfIndexByNameW(NULL, name, &index);
JENV->ReleaseStringChars(env, jname, name);
if (status == ERROR_SUCCESS) {
return index;
}
else {
win32_throw_exception(env, get_error_message(status));
return -1;
}
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -253,6 +253,8 @@ public class Pdh extends Win32 {
throws Win32Exception; throws Win32Exception;
private static final native String pdhLookupPerfName(int index) private static final native String pdhLookupPerfName(int index)
throws Win32Exception; throws Win32Exception;
private static final native int pdhLookupPerfIndex(String name)
throws Win32Exception;
/** /**
* Main method for dumping the entire PDH * Main method for dumping the entire PDH