Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-05-16 13:02:45 -0400
committerDoug Schaefer2007-05-16 13:02:45 -0400
commitc773868cfdd5c29479ff8a3b4366d2de23c012b4 (patch)
treee3facb8b02d794a2f54b3fc0f19f718ba2371c11 /core/org.eclipse.cdt.core.win32/library
parentfddd30f6bcdb6b2247fe96eabd8242f630dacb72 (diff)
downloadorg.eclipse.cdt-c773868cfdd5c29479ff8a3b4366d2de23c012b4.tar.gz
org.eclipse.cdt-c773868cfdd5c29479ff8a3b4366d2de23c012b4.tar.xz
org.eclipse.cdt-c773868cfdd5c29479ff8a3b4366d2de23c012b4.zip
Patch for Ken Ryall - 186436 - add getLocalMachineKeyName() native method.
Diffstat (limited to 'core/org.eclipse.cdt.core.win32/library')
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp
index 81367b9e47..c10d37a253 100644
--- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp
+++ b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp
@@ -78,3 +78,43 @@ JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMac
return result;
}
+
+/*
+ * Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
+ * to the key's array of keys, return the name of the indexed key.
+ * The return value is null on any error or when the index is invalid.
+ */
+
+extern "C"
+JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineKeyName(
+ JNIEnv * env, jobject obj, jstring subkey, jint index)
+{
+ const jchar * csubkey = env->GetStringChars(subkey, NULL);
+ jstring result = NULL;
+
+ HKEY key;
+ LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (const wchar_t *)csubkey, 0, KEY_READ, &key);
+ if (rc != ERROR_SUCCESS)
+ return NULL;
+
+ wchar_t keyName[256];
+ DWORD nameSize = sizeof(keyName) + 2;
+
+ rc = RegEnumKeyEx(key, index,
+ keyName, // UNICODE string
+ &nameSize,
+ NULL, NULL,
+ NULL,
+ NULL); // size in BYTE of data.
+
+ if (rc == ERROR_SUCCESS)
+ {
+ result = env->NewString((jchar *)keyName, nameSize);
+ }
+
+ RegCloseKey(key);
+
+ env->ReleaseStringChars(subkey, csubkey);
+
+ return result;
+}

Back to the top