View | Details | Raw Unified | Return to bug 140079 | Differences between
and this patch

Collapse All | Expand All

(-)WindowsRegistry.java (+11 lines)
Lines 44-47 Link Here
44
	 */
44
	 */
45
	public native String getLocalMachineValue(String subkey, String name);
45
	public native String getLocalMachineValue(String subkey, String name);
46
	
46
	
47
	/**
48
	 * Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
49
	 * to the key's array of values, return the name of the indexed value. 
50
	 * The return value is null on any error or when the index is invalid.
51
	 * The value name can be used in the above getLocalMachineValue() to retrieve
52
	 * the value data.
53
	 * @param subkey   subkey of HKEY_LOCAL_MACHINE
54
	 * @param index    index to the subkey's array of values, starting from 0. 
55
	 * @return name of registry value or null if not found
56
	 */
57
	public native String getLocalMachineValueName(String subkey, int index);
47
}
58
}
(-)winreg.cpp (+40 lines)
Lines 28-30 Link Here
28
28
29
	return result;
29
	return result;
30
}
30
}
31
32
/*
33
 * Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
34
 * to the key's array of values, return the name of the indexed value. 
35
 * The return value is null on any error or when the index is invalid.
36
 */
37
 
38
extern "C"
39
JNIEXPORT jstring Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName(
40
	JNIEnv * env, jobject obj, jstring subkey, jint index)
41
{
42
	const jchar * csubkey = env->GetStringChars(subkey, NULL);
43
	jstring 	result = NULL;
44
45
	HKEY key;
46
	LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (const wchar_t *)csubkey, 0, KEY_READ, &key);
47
	if (rc != ERROR_SUCCESS)
48
		return NULL;
49
	
50
	wchar_t valueName[256];
51
	DWORD 	nameSize = sizeof(valueName) + 2;
52
	
53
	rc = RegEnumValue(key, index, 
54
			valueName, 		// UNICODE string
55
			&nameSize, 
56
			NULL, NULL, 
57
			NULL, 			// data string
58
			NULL);			// size in BYTE of data.
59
	
60
	if (rc == ERROR_SUCCESS)
61
	{
62
		result = env->NewString((jchar *)valueName, nameSize);
63
	}
64
	
65
	RegCloseKey(key);
66
	
67
	env->ReleaseStringChars(subkey, csubkey);
68
69
	return result;
70
}

Return to bug 140079