}
}
public static void writeIntRegistryValue(String key, int data) {
Project p = new Project();
ExecTask exec = new ExecTask();
exec.setProject(p);
exec.setTaskType("reg");
exec.setExecutable(findReg());
exec.setFailonerror(false);
exec.setResultProperty("result");
exec.setOutputproperty("output");
if (isRegExeVersion1()) {
if (doesRegistryValueExist(key)) {
exec.createArg().setValue("update");
exec.createArg().setValue(key + "=" + Integer.toString(data));
} else {
exec.createArg().setValue("add");
exec.createArg().setValue(key + "=" + Integer.toString(data));
exec.createArg().setValue("REG_DWORD");
}
} else {
exec.createArg().setValue("add");
RegKeyValue r = new RegKeyValue(key);
exec.createArg().setValue(r.key);
exec.createArg().setValue("/v");
exec.createArg().setValue(r.value);
exec.createArg().setValue("/t");
exec.createArg().setValue("REG_DWORD");
exec.createArg().setValue("/d");
exec.createArg().setValue(Integer.toString(data));
exec.createArg().setValue("/f");
}
exec.execute();
String result = p.getProperty("result");
String output = p.getProperty("output");
if (!"0".equals(result)) {
throw new WindowsRegistryException("exec return code " + result + ": " + output);
}