|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.moyosoft.connector.registry.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();
}
Method Summary | |
static RegistryKey |
getCurrentConfigKey()
Returns the registry key HKEY_CURRENT_CONFIG. |
static RegistryKey |
getCurrentUserKey()
Returns the registry key HKEY_CURRENT_USER. |
static RegistryKey |
getLocalMachineKey()
Returns the registry key HKEY_LOCAL_MACHINE. |
static RegistryKey |
getUsersKey()
Returns the registry key HKEY_USERS. |
static RegistryKey |
openCurrentConfigKey(java.lang.String subKey)
Opens the specified sub-key of the registry key HKEY_CURRENT_CONFIG. |
static RegistryKey |
openCurrentUserKey(java.lang.String subKey)
Opens the specified sub-key of the registry key HKEY_CURRENT_USER. |
static RegistryKey |
openLocalMachineKey(java.lang.String subKey)
Opens the specified sub-key of the registry key HKEY_LOCAL_MACHINE. |
static RegistryKey |
openUsersKey(java.lang.String subKey)
Opens the specified sub-key of the registry key HKEY_USERS. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static RegistryKey getCurrentUserKey() throws RegistryException
RegistryException
- if any error occurs.public static RegistryKey openCurrentUserKey(java.lang.String subKey) throws RegistryException
subKey
- the sub-key to be opened.
RegistryException
- if any error occurs.public static RegistryKey getUsersKey() throws RegistryException
RegistryException
- if any error occurs.public static RegistryKey openUsersKey(java.lang.String subKey) throws RegistryException
subKey
- the sub-key to be opened.
RegistryException
- if any error occurs.public static RegistryKey getCurrentConfigKey() throws RegistryException
RegistryException
- if any error occurs.public static RegistryKey openCurrentConfigKey(java.lang.String subKey) throws RegistryException
subKey
- the sub-key to be opened.
RegistryException
- if any error occurs.public static RegistryKey getLocalMachineKey() throws RegistryException
RegistryException
- if any error occurs.public static RegistryKey openLocalMachineKey(java.lang.String subKey) throws RegistryException
subKey
- the sub-key to be opened.
RegistryException
- if any error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |