com.denova.runtime
Class WindowsRegistry

java.lang.Object
  |
  +--com.denova.runtime.WindowsCmdFile
        |
        +--com.denova.runtime.WindowsRegistry
All Implemented Interfaces:
WindowsConstants

public class WindowsRegistry
extends com.denova.runtime.WindowsCmdFile
implements WindowsConstants

Access the Windows registry.

Author:
DeNova Copyright © 1997-2008 DeNova All rights reserved worldwide.

Field Summary
 
Fields inherited from interface com.denova.runtime.WindowsConstants
AddRegistryEntry, AllUsers, AppendRegistryEntry, BinaryType, CurrentUser, DeleteRegistryEntry, DesktopSpecFilename, DirectoryResultsFilename, DWordType, EnumKeyRegistryEntry, EnumValueRegistryEntry, EnvOutputFilename, ExistsRegistryEntry, FreeDiskSpaceResultsFilename, InvokerFilename, MenuSpecFilename, NtResultsFilename, PathOutputFilename, PrependRegistryEntry, QueryRegistryEntry, RegistryResultsFilename, RegistrySpecFilename, ReplaceRegistryEntry, ShortnameFilename, StringType, WindowsAddDesktop, WindowsAddProgramsMenu, WindowsAddStartupMenu, WindowsAppDataCommand, WindowsCmdLogFilename, WindowsCommandsFilename, WindowsDelDesktop, WindowsDelProgramsMenu, WindowsDelStartupMenu, WindowsDesktopCommand, WindowsDesktopDirCommand, WindowsDirCommand, WindowsEnvVariableCommand, WindowsFreeDiskSpaceCommand, WindowsMenusDirCommand, WindowsNtCommand, WindowsPathCommand, WindowsPathShortenerCommand, WindowsProgramManagerDirCommand, WindowsProgramsMenuCommand, WindowsRegistryEditorCommand, WindowsStartupMenuCommand, WindowsStartupMenusDirCommand
 
Constructor Summary
WindowsRegistry()
           
 
Method Summary
static boolean addSubkey(java.lang.String keyName, java.lang.String subKeyName, java.lang.Integer subKeyData)
          Adds the subKeyName and its data to the registry if and only if it doesn't already exist.
static boolean addSubkey(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Adds the subKeyName and its data to the registry if and only if it doesn't already exist.
static boolean appendData(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Append subKeyData to the existing data for subKeyName.
static boolean deleteSubkey(java.lang.String keyName, java.lang.String subKeyName)
          Delete subKeyName from registry.
static java.util.List enumerate(java.lang.String keyName, java.lang.String subKeyName)
          Enumerate the keys in the subKeyName.
static java.util.List enumerateData(java.lang.String keyName, java.lang.String subKeyName)
          Enumerate the values in the subKeyName.
static boolean exists(java.lang.String fullKey)
          Determines if the key exists or not.
static boolean exportEntries(java.lang.String regFilename, java.lang.String regKey)
          Export part of Windows registry to a file.
static java.lang.String getData(java.lang.String keyName, java.lang.String subKeyName)
          Get the subKeyData for subKeyName.
static boolean importEntries(java.lang.String regFilename)
          Import regFilename into Windows registry.
static boolean prependData(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Prepend subKeyData to the existing data for subKeyName.
static boolean replaceBinaryData(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Replaces the binary data for the subKeyName.
static boolean replaceData(java.lang.String keyName, java.lang.String subKeyName, java.lang.Integer subKeyData)
          Replaces the data for the subKeyName.
static boolean replaceData(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Replaces the data for the subKeyName.
static java.lang.String toUnicode(java.lang.String ascii)
          Convert an ASCII string to a UNICODE hex string.
 
Methods inherited from class com.denova.runtime.WindowsCmdFile
getCommandProgram, getCommandProgramFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowsRegistry

public WindowsRegistry()
Method Detail

getData

public static java.lang.String getData(java.lang.String keyName,
                                       java.lang.String subKeyName)
Get the subKeyData for subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
Returns:
the data if successful; otherwise, returns null.


addSubkey

public static boolean addSubkey(java.lang.String keyName,
                                java.lang.String subKeyName,
                                java.lang.String subKeyData)
Adds the subKeyName and its data to the registry if and only if it doesn't already exist.

Returns true if add successful.
The keyName must already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the string data, if any, for the subKeyName
Returns:
success

addSubkey

public static boolean addSubkey(java.lang.String keyName,
                                java.lang.String subKeyName,
                                java.lang.Integer subKeyData)
Adds the subKeyName and its data to the registry if and only if it doesn't already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the DWORD data, if any, for the subKeyName
Returns:
true if add successful.
The keyName must already exist.


replaceData

public static boolean replaceData(java.lang.String keyName,
                                  java.lang.String subKeyName,
                                  java.lang.String subKeyData)
Replaces the data for the subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the string data, if any, for the subKeyName
Returns:
true if data successfully replaced.
If subKeyName does not exist, then it adds the subKeyName and its associated subKeyData.
The keyName must already exist.


replaceData

public static boolean replaceData(java.lang.String keyName,
                                  java.lang.String subKeyName,
                                  java.lang.Integer subKeyData)
Replaces the data for the subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the DWORD data, if any, for the subKeyName
Returns:
true if data successfully replaced.
If subKeyName does not exist, then it adds the subKeyName and its associated subKeyData.
The keyName must already exist.


replaceBinaryData

public static boolean replaceBinaryData(java.lang.String keyName,
                                        java.lang.String subKeyName,
                                        java.lang.String subKeyData)
Replaces the binary data for the subKeyName.

The data should be hex encoded into subKeyData. If the hex code is of unicode characters, then the hex must be stored low-endian (e.g., the letters mike would be 6d0069006b006500) No extra notation (0x or commas should be used to designate that the string is a series of hex numbers).

If subKeyName does not exist, then it adds the subKeyName and its associated subKeyData.
The keyName must already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the string data, if any, for the subKeyName
Returns:
true if data successfully replaced.

appendData

public static boolean appendData(java.lang.String keyName,
                                 java.lang.String subKeyName,
                                 java.lang.String subKeyData)
Append subKeyData to the existing data for subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the data, if any, for the subKeyName
Returns:
true if data successfully appended.
If subKeyName does not exist, then it adds the subKeyName and then adds the subKeyData.
The keyName must already exist.

You must include any required separators between the existing data and the new data.


prependData

public static boolean prependData(java.lang.String keyName,
                                  java.lang.String subKeyName,
                                  java.lang.String subKeyData)
Prepend subKeyData to the existing data for subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
subKeyData - the String data, if any, for the subKeyName
Returns:
true if data successfully prepended.
If subKeyName does not exist, then it adds the subKeyName and then adds the subKeyData.
The keyName must already exist.

You must include any required separators between the existing data and the new data.


deleteSubkey

public static boolean deleteSubkey(java.lang.String keyName,
                                   java.lang.String subKeyName)
Delete subKeyName from registry.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
Returns:
true if subKeyName successfully deleted.


exists

public static boolean exists(java.lang.String fullKey)
Determines if the key exists or not.

Parameters:
fullKey - the full key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
Returns:
true if it exists; otherwise, returns false.


enumerate

public static java.util.List enumerate(java.lang.String keyName,
                                       java.lang.String subKeyName)
Enumerate the keys in the subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
Returns:
the data if successful; otherwise, returns null.


enumerateData

public static java.util.List enumerateData(java.lang.String keyName,
                                           java.lang.String subKeyName)
Enumerate the values in the subKeyName.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows)
subKeyName - the last element of the key
Returns:
the data if successful; otherwise, returns null.


importEntries

public static boolean importEntries(java.lang.String regFilename)
Import regFilename into Windows registry.

Parameters:
regFilename - full pathname for the .reg file

Runs Regedit.exe or Regedit32.exe from the Windows directory and passes the regFilename as a parameter.

regFilename and Regedit.Exe or Regedit32.exe must exist to be successful.

Returns:
true if successful.


exportEntries

public static boolean exportEntries(java.lang.String regFilename,
                                    java.lang.String regKey)
Export part of Windows registry to a file.

Parameters:
regFilename - full pathname for the export file
regKey - key to start the export

Runs Regedit.exe or Regedit32.exe from the Windows directory and passes the regFilename as a parameter.

regFilename and Regedit.Exe or Regedit32.exe must exist to be successful.

Returns:
true if successful.


toUnicode

public static java.lang.String toUnicode(java.lang.String ascii)
Convert an ASCII string to a UNICODE hex string.

Parameters:
ascii - ASCI string
Returns:
UNICODE hex string