private void check(int r) { if (r != WINERROR.ERROR_SUCCESS) throw new JnaException(r); }
/** * 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; } }
private byte[] getValue(String valueName) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, valueName, null, pType, lpData, lpcbData); switch (r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_SUCCESS: return lpData; } throw new JnaException(r); } }
/** * 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; } }
/** * Does a specified value exist? */ public boolean valueExists(String name) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData); switch(r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_FILE_NOT_FOUND: return false; case WINERROR.ERROR_SUCCESS: return true; default: throw new JnaException(r); } } }
/** * 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; } }
private void check(int r) { if (r != WINERROR.ERROR_SUCCESS) throw new JnaException(r); }
/** * 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; } }
private void check(int r) { if (r != WINERROR.ERROR_SUCCESS) throw new JnaException(r); }
private void check(int r) { if (r != WINERROR.ERROR_SUCCESS) throw new JnaException(r); }
/** * Does a specified value exist? */ public boolean valueExists(String name) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, new IntByReference(), new byte[1], new IntByReference()); switch(r) { case WINERROR.ERROR_FILE_NOT_FOUND: return false; case WINERROR.ERROR_SUCCESS: return true; default: throw new JnaException(r); } }
/** * Does a specified value exist? */ public boolean valueExists(String name) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, new IntByReference(), new byte[1], new IntByReference()); switch(r) { case WINERROR.ERROR_FILE_NOT_FOUND: return false; case WINERROR.ERROR_SUCCESS: return true; default: throw new JnaException(r); } }
private byte[] getValue(String valueName) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, valueName, null, pType, lpData, lpcbData); switch (r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_SUCCESS: return lpData; } throw new JnaException(r); } }
private byte[] getValue(String valueName) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, valueName, null, pType, lpData, lpcbData); switch (r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_SUCCESS: return lpData; } throw new JnaException(r); } }
private byte[] getValue(String valueName) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, valueName, null, pType, lpData, lpcbData); switch (r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_SUCCESS: return lpData; } throw new JnaException(r); } }
/** * Does a specified value exist? */ public boolean valueExists(String name) { IntByReference pType, lpcbData; byte[] lpData = new byte[1]; pType = new IntByReference(); lpcbData = new IntByReference(); OUTER: while(true) { int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData); switch(r) { case WINERROR.ERROR_MORE_DATA: lpData = new byte[lpcbData.getValue()]; continue OUTER; case WINERROR.ERROR_FILE_NOT_FOUND: return false; case WINERROR.ERROR_SUCCESS: return true; default: throw new JnaException(r); } } }