Merge branch 'sigar-1.6'
This commit is contained in:
commit
bdfd156a63
3 files changed
+89
-1
No files matched your search
@@ -222,6 +222,55 @@ JNIEXPORT jdouble SIGAR_JNI(win32_Pdh_pdhGetValue)
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jstring SIGAR_JNI(win32_Pdh_pdhGetDescription)
|
||||
(JNIEnv *env, jclass cur, jlong counter)
|
||||
{
|
||||
HCOUNTER h_counter = (HCOUNTER)counter;
|
||||
PDH_COUNTER_INFO *info = NULL;
|
||||
jstring retval = NULL;
|
||||
DWORD size = 0;
|
||||
PDH_STATUS status;
|
||||
|
||||
status = PdhGetCounterInfo(h_counter, TRUE, &size, NULL);
|
||||
if (status != PDH_MORE_DATA) {
|
||||
win32_throw_exception(env, get_error_message(status));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
info = malloc(size);
|
||||
|
||||
status = PdhGetCounterInfo(h_counter, 1, &size, info);
|
||||
if (status == ERROR_SUCCESS) {
|
||||
if (info->szExplainText) {
|
||||
retval = JENV->NewString(env, info->szExplainText,
|
||||
lstrlen(info->szExplainText));
|
||||
}
|
||||
}
|
||||
else {
|
||||
win32_throw_exception(env, get_error_message(status));
|
||||
}
|
||||
|
||||
free(info);
|
||||
return retval;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong SIGAR_JNI(win32_Pdh_pdhGetCounterType)
|
||||
(JNIEnv *env, jclass cur, jlong counter)
|
||||
{
|
||||
HCOUNTER h_counter = (HCOUNTER)counter;
|
||||
PDH_COUNTER_INFO info;
|
||||
DWORD size = sizeof(info);
|
||||
PDH_STATUS status;
|
||||
|
||||
status = PdhGetCounterInfo(h_counter, FALSE, &size, &info);
|
||||
if (status != ERROR_SUCCESS) {
|
||||
win32_throw_exception(env, get_error_message(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return info.dwType;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray SIGAR_JNI(win32_Pdh_pdhGetInstances)
|
||||
(JNIEnv *env, jclass cur, jstring cp)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user