Moyosoft Products | Services | Download | Contact us    
Java Outlook Connector
Products  >  Java Outlook Connector  >  API Reference    
API Reference
   
Overview  |  
Classic JavaDoc

Class Registry

java.lang.Object
  └ com.moyosoft.connector.registry.Registry


public final class Registry

Provides access to Windows Registry. This class has static methods used to get the root registry keys such as HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, etc.

Example source code:

// Load the native library:
System.loadLibrary("moyocore");

// Get the location of the Program Files folder from the registy:
String programFilesPath = Registry.getLocalMachineKey().getValue(
    "SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
    "ProgramFilesDir").getString();

System.out.println("ProgramFilesDir = " + programFilesPath);
System.out.println();

// Create a new key:
RegistryKey registryKey = Registry.getLocalMachineKey().createKey("SOFTWARE\\TestMoyosoft");

try
{
    // Add some values:
    registryKey.setValue("Test value", "This is a test value");
    registryKey.setValue("Numeric value", 123);
    registryKey.setValue("Binary value", new byte[] {0x01, 0x02, 0x03});

    // Set the key's Default value:
    registryKey.setValue("", new RegistryValue(456));

    // Iterate through all values in this registry key:
    for(Iterator it = registryKey.getValues(); it.hasNext(); )
    {
        String valueName = (String) it.next();

        System.out.println("Value name: " + valueName);
        System.out.println("Value: " + registryKey.getValue(valueName));
        System.out.println();
    }

    // Iterate through all sub-keys in this registry key:
    for(Iterator it = registryKey.getSubKeys(); it.hasNext(); )
    {
        System.out.println("Key name: " + (String) it.next());
    }

    // Delete the previously created values:
    registryKey.deleteValue("Test value");
    registryKey.deleteValue("Numeric value");
    registryKey.deleteValue("Binary value");
    registryKey.deleteValue("");
}
finally
{
    // Close the registry key:
    registryKey.close();
}

Methods

getCurrentConfigKey ()
Returns the registry key HKEY_CURRENT_CONFIG.
getCurrentUserKey ()
Returns the registry key HKEY_CURRENT_USER.
getLocalMachineKey ()
Returns the registry key HKEY_LOCAL_MACHINE.
getUsersKey ()
Returns the registry key HKEY_USERS.
openCurrentConfigKey (String subKey)
Opens the specified sub-key of the registry key HKEY_CURRENT_CONFIG. If this method returns successfully, the returned RegistryKey object has to be closed using the method RegistryKey.close().
openCurrentUserKey (String subKey)
Opens the specified sub-key of the registry key HKEY_CURRENT_USER. If this method returns successfully, the returned RegistryKey object has to be closed using the method RegistryKey.close().
openLocalMachineKey (String subKey)
Opens the specified sub-key of the registry key HKEY_LOCAL_MACHINE. If this method returns successfully, the returned RegistryKey object has to be closed using the method RegistryKey.close().
openUsersKey (String subKey)
Opens the specified sub-key of the registry key HKEY_USERS. If this method returns successfully, the returned RegistryKey object has to be closed using the method RegistryKey.close().

Community comments



Powered by JavaDocPlus