/** * Set a long value in registry. * * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param name * Value name. * @param value * Value to write to registry. */ public static void registrySetLongValue(HKEY root, String keyPath, String name, long value) { registrySetLongValue(root, keyPath, name, value, 0); }
/** * Applies a Long(REG_QWORD) value on the specified key. * * The key will be created if does not exist. * The key type will be changed if needed. * * @param keyPath * @param keyName * @param keyValue */ @Override public void setLongValue( String rootKey, String keyPath, String keyName, long keyValue ) { log.info("Set Long value '" + keyValue + "' on: " + getDescription(rootKey, keyPath, keyName)); try { Advapi32Util.registrySetLongValue(getHKey(rootKey), keyPath, keyName, keyValue); } catch (RuntimeException re) { throw new RegistryOperationsException("Couldn't set registry Long value '" + keyValue + "' to: " + getDescription(rootKey, keyPath, keyName), re); } }
registrySetLongValue(phkKey.getValue(), name, value); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
/** * Set a long value in registry. * * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param name * Value name. * @param value * Value to write to registry. */ public static void registrySetLongValue(HKEY root, String keyPath, String name, long value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registrySetLongValue(phkKey.getValue(), name, value); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } }