Package org.openstreetmap.josm.tools
Class WinRegistry
java.lang.Object
org.openstreetmap.josm.tools.WinRegistry
Utility class to access Window registry (read access only).
As the implementation relies on internal JDK class
java.util.prefs.WindowsPreferences and its native JNI
method Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx, only String values (REG_SZ)
are supported.
Adapted from StackOverflow.- Since:
- 12217
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longRegistry entries subordinate to this key define the preferences of the current user.private static final Stringstatic final longRegistry entries subordinate to this key define the physical state of the computer, including data about the bus type, system memory, and installed hardware and software.private static final intprivate static final MethodWrapper for Windows registry API RegCloseKey(long) Returnsintprivate static final MethodWrapper for RegEnumKeyEx(long, int, int) Returnsbyte[]private static final MethodWrapper for Windows registry API RegEnumValue(long, int, int) Returnsbyte[]private static final MethodWrapper for Windows registry API RegOpenKey(long, byte[], int) Returnslong[]private static final MethodWrapper for RegQueryInfoKey(long) Returnslong[]private static final MethodWrapper for Windows registry API RegQueryValueEx(long, byte[]) Returnsbyte[]private static final longprivate static final Preferencesprivate static final Class<? extends Preferences>private static final Preferences -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static MethodgetDeclaredMethod(String name, Class<?>... parameterTypes) private static longstatic StringreadString(long hkey, String key, String valueName) Read a value from key and value nameprivate static StringreadString(Preferences root, long hkey, String key, String value) readStringSubKeys(long hkey, String key) Read the value name(s) from a given keyreadStringSubKeys(Preferences root, long hkey, String key) readStringValues(long hkey, String key) Read value(s) and value name(s) form given keyreadStringValues(Preferences root, long hkey, String key) private static byte[]
-
Field Details
-
HKEY_CURRENT_USER
Registry entries subordinate to this key define the preferences of the current user. These preferences include the settings of environment variables, data about program groups, colors, printers, network connections, and application preferences. See Predefined Keys- See Also:
-
HKEY_LOCAL_MACHINE
Registry entries subordinate to this key define the physical state of the computer, including data about the bus type, system memory, and installed hardware and software. It contains subkeys that hold current configuration data, including Plug and Play information (the Enum branch, which includes a complete list of all hardware that has ever been on the system), network logon preferences, network security information, software-related information (such as server names and the location of the server), and other system information. See Predefined Keys- See Also:
-
REG_SUCCESS
- See Also:
-
KEY_READ
- See Also:
-
USER_ROOT
-
SYSTEM_ROOT
-
USER_CLASS
-
HKEY_EQ
- See Also:
-
REG_OPEN_KEY
Wrapper for Windows registry API RegOpenKey(long, byte[], int) Returnslong[] -
REG_CLOSE_KEY
Wrapper for Windows registry API RegCloseKey(long) Returnsint -
REG_QUERY_VALUE_EX
Wrapper for Windows registry API RegQueryValueEx(long, byte[]) Returnsbyte[] -
REG_ENUM_VALUE
Wrapper for Windows registry API RegEnumValue(long, int, int) Returnsbyte[] -
REG_QUERY_INFO_KEY
Wrapper for RegQueryInfoKey(long) Returnslong[] -
REG_ENUM_KEY_EX
Wrapper for RegEnumKeyEx(long, int, int) Returnsbyte[]
-
-
Constructor Details
-
WinRegistry
private WinRegistry()
-
-
Method Details
-
getDeclaredMethod
-
readString
public static String readString(long hkey, String key, String valueName) throws IllegalAccessException, InvocationTargetException Read a value from key and value name- Parameters:
hkey- HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEkey- key namevalueName- value name- Returns:
- the value
- Throws:
IllegalArgumentException- if hkey not HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEIllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception- Since:
- 19100 (method definition)
-
readStringValues
public static Map<String,String> readStringValues(long hkey, String key) throws IllegalAccessException, InvocationTargetException Read value(s) and value name(s) form given key- Parameters:
hkey- HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEkey- key name- Returns:
- the value name(s) plus the value(s)
- Throws:
IllegalArgumentException- if hkey not HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEIllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception
-
readStringSubKeys
public static List<String> readStringSubKeys(long hkey, String key) throws IllegalAccessException, InvocationTargetException Read the value name(s) from a given key- Parameters:
hkey- HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEkey- key name- Returns:
- the value name(s)
- Throws:
IllegalArgumentException- if hkey not HKEY_CURRENT_USER/HKEY_LOCAL_MACHINEIllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception
-
getNumber
-
readString
private static String readString(Preferences root, long hkey, String key, String value) throws IllegalAccessException, InvocationTargetException -
readStringValues
private static Map<String,String> readStringValues(Preferences root, long hkey, String key) throws IllegalAccessException, InvocationTargetException -
readStringSubKeys
private static List<String> readStringSubKeys(Preferences root, long hkey, String key) throws IllegalAccessException, InvocationTargetException -
toCstr
-