mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Patch for Ling@nokia. New entry to windows registry utility.
This commit is contained in:
parent
0bdb8b262e
commit
cb183a6622
3 changed files with 53 additions and 1 deletions
|
@ -28,3 +28,43 @@ JNIEXPORT jstring Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValu
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
|
||||||
|
* to the key's array of values, return the name of the indexed value.
|
||||||
|
* The return value is null on any error or when the index is invalid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jstring Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName(
|
||||||
|
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 valueName[256];
|
||||||
|
DWORD nameSize = sizeof(valueName) + 2;
|
||||||
|
|
||||||
|
rc = RegEnumValue(key, index,
|
||||||
|
valueName, // UNICODE string
|
||||||
|
&nameSize,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL, // data string
|
||||||
|
NULL); // size in BYTE of data.
|
||||||
|
|
||||||
|
if (rc == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
result = env->NewString((jchar *)valueName, nameSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(key);
|
||||||
|
|
||||||
|
env->ReleaseStringChars(subkey, csubkey);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
|
@ -44,4 +44,16 @@ public class WindowsRegistry {
|
||||||
*/
|
*/
|
||||||
public native String getLocalMachineValue(String subkey, String name);
|
public native String getLocalMachineValue(String subkey, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
|
||||||
|
* to the key's array of values, return the name of the indexed value.
|
||||||
|
* The return value is null on any error or when the index is invalid.
|
||||||
|
* The value name can be used in the above getLocalMachineValue() to retrieve
|
||||||
|
* the value data.
|
||||||
|
* @param subkey subkey of HKEY_LOCAL_MACHINE
|
||||||
|
* @param index index to the subkey's array of values, starting from 0.
|
||||||
|
* @return name of registry value or null if not found
|
||||||
|
*/
|
||||||
|
public native String getLocalMachineValueName(String subkey, int index);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue