public void testRegistryDeleteValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue", 42); assertTrue( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); Advapi32Util.registryDeleteValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue"); assertFalse( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }
public void testRegistryValueExists() { assertFalse( Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft", "")); assertFalse( Advapi32Util.registryValueExists( WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft", "KeyDoesNotExist")); assertTrue( Advapi32Util.registryValueExists( WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control", "SystemBootDevice")); }
public void testRegistrySetGetLongValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetLongValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "LongValue", 1234L); assertEquals( 1234L, Advapi32Util.registryGetLongValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "LongValue")); assertTrue( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "LongValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }
public void testRegistrySetGetExpandableStringValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetExpandableStringValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue", "Temp is %TEMP%"); assertEquals( "Temp is %TEMP%", Advapi32Util.registryGetExpandableStringValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); assertTrue( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }
public void testRegistrySetGetStringValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetStringValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue", "Hello World"); assertEquals( "Hello World", Advapi32Util.registryGetStringValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); assertTrue( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }
public void testRegistrySetGetBinaryValue() { byte[] data = {0x00, 0x01, 0x02}; Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetBinaryValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "BinaryValue", data); byte[] read = Advapi32Util.registryGetBinaryValue( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "BinaryValue"); assertEquals(data.length, read.length); for (int i = 0; i < data.length; i++) { assertEquals(data[i], read[i]); } assertTrue( Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "BinaryValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }
public void testRegistrySetGetStringArray() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); String[] dataWritten = {"Hello", "World"}; Advapi32Util.registrySetStringArray( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "MultiStringValue", dataWritten); assertTrue( Advapi32Util.registryValueExists( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "MultiStringValue")); String[] dataRead = Advapi32Util.registryGetStringArray( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "MultiStringValue"); assertEquals(dataWritten.length, dataRead.length); for (int i = 0; i < dataRead.length; i++) { assertEquals(dataWritten[i], dataRead[i]); } dataWritten = new String[0]; Advapi32Util.registrySetStringArray( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyMultiString", dataWritten); dataRead = Advapi32Util.registryGetStringArray( WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyMultiString"); assertEquals(0, dataRead.length); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); }