add PdhValidatePath wrapper

This commit is contained in:
Doug MacEachern 2007-03-05 21:24:03 +00:00
parent 98fd0fdbcc
commit c2296865e2
3 changed files with 20 additions and 10 deletions

View File

@ -70,6 +70,21 @@ static char *get_error_message(PDH_STATUS status) {
}
}
JNIEXPORT jlong SIGAR_JNI(win32_Pdh_validate)
(JNIEnv *env, jclass cur, jstring jpath)
{
PDH_STATUS status;
jboolean is_copy;
LPCTSTR path = JENV->GetStringChars(env, jpath, &is_copy);
status = PdhValidatePath(path);
if (is_copy) {
JENV->ReleaseStringChars(env, jpath, path);
}
return status;
}
JNIEXPORT void SIGAR_JNI(win32_Pdh_pdhConnectMachine)
(JNIEnv *env, jobject cur, jstring jhost)
{

View File

@ -243,6 +243,8 @@ public class Pdh extends Win32 {
return pdhGetObjects();
}
public static final native long validate(String path);
private static final native void pdhConnectMachine(String host)
throws Win32Exception;
private static final native long pdhOpenQuery() throws Win32Exception;

View File

@ -58,19 +58,12 @@ public class TestPdh extends SigarTestCase {
if (!trans.equals(path)) {
traceln(path + "-->" + trans);
}
traceln(path + " validate: " + Pdh.validate(path));
getValue(path);
}
/* XXX hangs for a while on my XP box
String bogusKey = "\\Does Not\\Exist";
try {
new Pdh().getRawValue(bogusKey);
assertTrue(false);
} catch (Win32Exception e) {
assertTrue(true);
traceln(bogusKey + "=" + e.getMessage());
}
*/
assertTrue(Pdh.validate(bogusKey) != 0);
}
public void testCounterMap() throws Exception {