/** * Read an int value. */ public int getIntValue(String valueName) { return convertBufferToInt(getValue(valueName)); }
public RegistryKey open(String subKeyName, int access) { IntByReference pHandle = new IntByReference(); check(Advapi32.INSTANCE.RegOpenKeyEx(handle, subKeyName, 0, access, pHandle)); return new RegistryKey(this,subKeyName,pHandle.getValue()); }
private RegistryKey(RegistryKey ancestor, String path,int handle) { this.handle = handle; this.root = ancestor.root; this.path = combine(ancestor.path,path); }
public String getStringValue(String valueName) { return convertBufferToString(getValue(valueName)); }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accommodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
values.put(name, convertBufferToString(lpData)); break; case WINNT.REG_DWORD: values.put(name, convertBufferToInt(lpData)); break; default: check(result);
/** * Writes a DWORD value. */ public void setValue(String name, int value) { byte[] data = new byte[4]; data[0] = (byte) (value & 0xff); data[1] = (byte) ((value >> 8) & 0xff); data[2] = (byte) ((value >> 16) & 0xff); data[3] = (byte) ((value >> 24) & 0xff); check(Advapi32.INSTANCE.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length)); }
public RegistryKey open(String subKeyName) { return open(subKeyName,0xF003F/*KEY_ALL_ACCESS*/); }
@Override protected void finalize() throws Throwable { super.finalize(); dispose(); }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accommodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
lpData = new byte[lpcbData.getValue()]; lpcchValueName = new IntByReference(16384); check(Advapi32.INSTANCE.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null, lpType, lpData, lpcbData)); values.put(name, convertBufferToString(lpData)); break; case WINNT.REG_DWORD: values.put(name, convertBufferToInt(lpData)); break; default: check(result);
public String getStringValue(String valueName) { return convertBufferToString(getValue(valueName)); }
public void deleteValue(String valueName) { check(Advapi32.INSTANCE.RegDeleteValue(handle, valueName)); }
public RegistryKey openReadonly(String subKeyName) { return open(subKeyName,0x20019/*KEY_READ*/); }
@Override protected void finalize() throws Throwable { super.finalize(); dispose(); }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accomodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
lpData = new byte[lpcbData.getValue()]; lpcchValueName = new IntByReference(16384); check(Advapi32.INSTANCE.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null, lpType, lpData, lpcbData)); values.put(name, convertBufferToString(lpData)); break; case WINNT.REG_DWORD: values.put(name, convertBufferToInt(lpData)); break; default: check(result);