I'm currently trying to query and set some windows registry entries through a Java app. We are mandated to use the JNI-Registry library (for licensing reasons). The keys and values to set are not under my control (I'm modifying values set by another, 3rd party, application).
I can get and set the various entries and values OK for normal keys and values, and I can query the default value for a key OK. However, I need to know how to set the default values for a key.
//This works
final RegistryKey regKey = Registry.HKEY_LOCAL_MACHINE.openSubKey("SOFTWARE\\company\\app\\subkey", RegistryKey.ACCESS_ALL);
RegStringValue blah = (RegStringValue) regKey.getValue("blah");
if (blah == null) {
blah = new RegStringValue(regKey, "blah");
}
blah.setData("Some data");
regKey.setValue(blah);
//Not sure about this...
final RegistryKey regKey = Registry.HKEY_LOCAL_MACHINE.openSubKey("SOFTWARE\\company\\app\\subkey", RegistryKey.ACCESS_ALL);
String defaultValue = regKey.getDefaultValue(); //Gets the default value OK
//How do I reset it, though???
//need something like:
// regKey.setDefaultValue("Some new value");
//The following does not seem to work
RegDWordValue defVal = (RegDWordValue) regKey.getValue(""); //Also tried ...getValue("Default")
defVal.setData("Some new Value");
regKey.setValue(defVal);
regKey.closeKey();
Does anyone know if this is possible?