/** * Opens a registry key. * * @param baseKey One of the predefined keys, or a key previously returned by openKey. * @param keyPath Path relative to baseKey. * @return Handle to opened key. Null if not exists. */ private static Integer openKey(Integer baseKey, String keyPath) { return openKey(baseKey, keyPath, KEY_READ); }
/** * Opens the specified key path and reads the specified value. */ private static String readKeyValue(Integer keyHandle, String keyPath, String valueName) { Integer actualKeyHandle = null; try { // Open key: actualKeyHandle = openKey(keyHandle, keyPath); // If key does not exists, abort: if (actualKeyHandle == null) return null; // Read value: return queryKeyValue(actualKeyHandle, valueName); } finally { // Close key, if open: closeKey(actualKeyHandle); } }