ewex.registry
Class Registry

java.lang.Object
  extended byewex.registry.Registry

public class Registry
extends Object

This allows access to keys in the local system registry. It will be extended soon to cover accessing keys in a mobile pc registry.


Field Summary
static int ASSOCIATE_EWE_APPLICATION
          An option for associateFile().
static int ASSOCIATE_ICON_IS_RESOURCE
          An option for associateFile().
static int FOLDER_BITBUCKET
           
static int FOLDER_CONTROLS
           
static int FOLDER_DESKTOP
           
static int FOLDER_DESKTOPDIRECTORY
           
static int FOLDER_DRIVES
           
static int FOLDER_FAVORITES
           
static int FOLDER_FONTS
           
static int FOLDER_NETHOOD
           
static int FOLDER_NETWORK
           
static int FOLDER_PERSONAL
           
static int FOLDER_PRINTERS
           
static int FOLDER_PROGRAMS
           
static int FOLDER_RECENT
           
static int FOLDER_SENDTO
           
static int FOLDER_STARTMENU
           
static int FOLDER_STARTUP
           
static int FOLDER_TEMPLATES
           
static int FOLDER_WINDOWS
           
static int HKEY_CLASSES_ROOT
           
static int HKEY_CURRENT_CONFIG
           
static int HKEY_CURRENT_USER
           
static int HKEY_DYN_DATA
           
static int HKEY_LOCAL_MACHINE
           
static int HKEY_USERS
           
static int NOT_INITIALIZED_ERROR
           
static int PLATFORM_WIN32_NT
           
static int PLATFORM_WIN32_WINDOWS
           
static int PLATFORM_WIN32s
           
static String[] roots
           
static double testValue
           
 
Constructor Summary
Registry()
           
 
Method Summary
static void associateFile(String extension, String shortFileDescription, String fileDescription, String commandLine, String icon, int options)
          This associates files with a certain extension to a particular application.
static void associateFileWithMe(String extension, String shortFileDescription, String fileDescription, String icon)
          This associates files with a certain extension to the running Ewe application.
static void associateFileWithMe(String extension, String shortFileDescription, String fileDescription, String arguments, String icon, int options)
          This associates files with a certain extension to the running Ewe application.
static boolean createShortcut(String target, String arguments, String shortcutPath)
           
static String getEweCommandLine(String myEweFile, String extraArguments, String vmArguments, boolean includePathToVM)
          Create an absolute command line to execute the Ewe VM on my Ewe file.
static String getEweCommandLineToMe(String extraArguments, String vmArguments, boolean includePathToVM)
          Create an absolute command line to execute the Ewe VM on my Ewe file.
static RegistryKey getLocalKey(int root, String path, boolean fullAccess, boolean createIfDoesntExist)
          Get a key in the local registry.
static int getPlatform()
           
static RegistryKey getRemoteKey(int root, String path, boolean fullAccess, boolean createIfDoesntExist)
          Gets a remote key.
static String getSpecialFolder(int folder)
           
static boolean isInitialized(boolean forRemote)
           
static boolean isNativeInitialized()
          Returns true if a TRUE native registry is available.
protected static boolean loadLibrary(String libraryName)
           
static int toRootAndPath(String path, StringBuffer pathWithoutRoot)
          This converts a path that starts with a string representation of one of the roots to an int value which is one of the HKEY_ values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

testValue

public static double testValue

HKEY_CLASSES_ROOT

public static final int HKEY_CLASSES_ROOT
See Also:
Constant Field Values

HKEY_CURRENT_USER

public static final int HKEY_CURRENT_USER
See Also:
Constant Field Values

HKEY_LOCAL_MACHINE

public static final int HKEY_LOCAL_MACHINE
See Also:
Constant Field Values

HKEY_USERS

public static final int HKEY_USERS
See Also:
Constant Field Values

HKEY_CURRENT_CONFIG

public static final int HKEY_CURRENT_CONFIG
See Also:
Constant Field Values

HKEY_DYN_DATA

public static final int HKEY_DYN_DATA
See Also:
Constant Field Values

roots

public static String[] roots

PLATFORM_WIN32s

public static final int PLATFORM_WIN32s
See Also:
Constant Field Values

PLATFORM_WIN32_WINDOWS

public static final int PLATFORM_WIN32_WINDOWS
See Also:
Constant Field Values

PLATFORM_WIN32_NT

public static final int PLATFORM_WIN32_NT
See Also:
Constant Field Values

NOT_INITIALIZED_ERROR

public static final int NOT_INITIALIZED_ERROR
See Also:
Constant Field Values

FOLDER_WINDOWS

public static final int FOLDER_WINDOWS
See Also:
Constant Field Values

FOLDER_DESKTOP

public static final int FOLDER_DESKTOP
See Also:
Constant Field Values

FOLDER_PROGRAMS

public static final int FOLDER_PROGRAMS
See Also:
Constant Field Values

FOLDER_CONTROLS

public static final int FOLDER_CONTROLS
See Also:
Constant Field Values

FOLDER_PRINTERS

public static final int FOLDER_PRINTERS
See Also:
Constant Field Values

FOLDER_PERSONAL

public static final int FOLDER_PERSONAL
See Also:
Constant Field Values

FOLDER_FAVORITES

public static final int FOLDER_FAVORITES
See Also:
Constant Field Values

FOLDER_STARTUP

public static final int FOLDER_STARTUP
See Also:
Constant Field Values

FOLDER_RECENT

public static final int FOLDER_RECENT
See Also:
Constant Field Values

FOLDER_SENDTO

public static final int FOLDER_SENDTO
See Also:
Constant Field Values

FOLDER_BITBUCKET

public static final int FOLDER_BITBUCKET
See Also:
Constant Field Values

FOLDER_STARTMENU

public static final int FOLDER_STARTMENU
See Also:
Constant Field Values

FOLDER_DESKTOPDIRECTORY

public static final int FOLDER_DESKTOPDIRECTORY
See Also:
Constant Field Values

FOLDER_DRIVES

public static final int FOLDER_DRIVES
See Also:
Constant Field Values

FOLDER_NETWORK

public static final int FOLDER_NETWORK
See Also:
Constant Field Values

FOLDER_NETHOOD

public static final int FOLDER_NETHOOD
See Also:
Constant Field Values

FOLDER_FONTS

public static final int FOLDER_FONTS
See Also:
Constant Field Values

FOLDER_TEMPLATES

public static final int FOLDER_TEMPLATES
See Also:
Constant Field Values

ASSOCIATE_EWE_APPLICATION

public static final int ASSOCIATE_EWE_APPLICATION
An option for associateFile().

See Also:
Constant Field Values

ASSOCIATE_ICON_IS_RESOURCE

public static final int ASSOCIATE_ICON_IS_RESOURCE
An option for associateFile().

See Also:
Constant Field Values
Constructor Detail

Registry

public Registry()
Method Detail

loadLibrary

protected static boolean loadLibrary(String libraryName)

toRootAndPath

public static int toRootAndPath(String path,
                                StringBuffer pathWithoutRoot)
This converts a path that starts with a string representation of one of the roots to an int value which is one of the HKEY_ values. It will return 0 if a valid root was not found.


getLocalKey

public static RegistryKey getLocalKey(int root,
                                      String path,
                                      boolean fullAccess,
                                      boolean createIfDoesntExist)
Get a key in the local registry. If the path or root specified is invalid for any reason, it will return null. If the ewex_registry.dll could not be loaded, it will return null.

Note that the path MUST be separated by '\' characters and NOT '/' characters.

If a root of 0 is used, it will be assumed that the path will start with "HKEY_CLASSES_ROOT\..." or one of the other text representation of the roots. These roots are:
"HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE","HKEY_USERS","HKEY_CURRENT_CONFIG","HKEY_DYN_DATA"


getRemoteKey

public static RegistryKey getRemoteKey(int root,
                                       String path,
                                       boolean fullAccess,
                                       boolean createIfDoesntExist)
Gets a remote key. ewex.Rapi.initialize() must be called first. If the ewex_remote_registry.dll could not be loaded, this will return null.

If the path or root specified is invalid for any reason, it will return null. If the ewex_registry.dll could not be loaded, it will return null.

Note that the path MUST be separated by '\' characters and NOT '/' characters.

If a root of 0 is used, it will be assumed that the path will start with "HKEY_CLASSES_ROOT\..." or one of the other text representation of the roots. These roots are:
"HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE","HKEY_USERS","HKEY_CURRENT_CONFIG","HKEY_DYN_DATA"


isInitialized

public static boolean isInitialized(boolean forRemote)

isNativeInitialized

public static boolean isNativeInitialized()
Returns true if a TRUE native registry is available. False if not.


getPlatform

public static int getPlatform()

getSpecialFolder

public static String getSpecialFolder(int folder)

createShortcut

public static boolean createShortcut(String target,
                                     String arguments,
                                     String shortcutPath)

associateFile

public static void associateFile(String extension,
                                 String shortFileDescription,
                                 String fileDescription,
                                 String commandLine,
                                 String icon,
                                 int options)
                          throws IOException
This associates files with a certain extension to a particular application.

Parameters:
extension - This is the file extension (e.g. ".pnf")
shortFileDescription - This is a mandatory short file description (e.g. "JewelFile");
fileDescription - This is an optional long file description (e.g. "Jewel Program Specs")
commandLine - This is the command line to execute - it will usually include "%1" (including the quotes) within it to indicate where the file name gets inserted into the command line passed to the application. If you want to execute a .ewe file, then set the command line to point to the .ewe file (in quotes) and then set options to be ASSOCIATE_EWE_APPLICATION.
icon - The file name of an optional icon to associate with files of this extension.
options - Can be any of the following values ORed together:
ASSOCIATE_ICON_IS_RESOURCE - this indicates that the specified icon resides as a resource with the application and should be extracted and saved to the file system if necessary. If this is not selected then the icon is assumed to be an absoulte file name.
ASSOCIATE_EWE_APPLICATION - this indicates that the Ewe VM should be used to start the application.
Throws:
IOException - If an error occurs saving the registry information.

associateFileWithMe

public static void associateFileWithMe(String extension,
                                       String shortFileDescription,
                                       String fileDescription,
                                       String arguments,
                                       String icon,
                                       int options)
                                throws IOException
This associates files with a certain extension to the running Ewe application. The running application should be run from a ".ewe" file or from a ".exe" file created from a ".ewe" file.

Parameters:
extension - This is the file extension (e.g. ".pnf")
shortFileDescription - This is a mandatory short file description (e.g. "JewelFile");
fileDescription - This is an optional long file description (e.g. "Jewel Program Specs")
arguments - These are the arguments to pass to the application - it will usually include "%1" (including the quotes) within it to indicate where the file name gets inserted into the command line passed to the application.
icon - The file name of an optional icon to associate with files of this extension.
options - Can be any of the following values ORed together:
ASSOCIATE_ICON_IS_RESOURCE - this indicates that the specified icon resides as a resource with the application and should be extracted and saved to the file system if necessary. If this is not selected then the icon is assumed to be an absolute file name.
Throws:
IOException - If an error occurs saving the registry information.

associateFileWithMe

public static void associateFileWithMe(String extension,
                                       String shortFileDescription,
                                       String fileDescription,
                                       String icon)
                                throws IOException
This associates files with a certain extension to the running Ewe application. The running application should be run from a ".ewe" file or from a ".exe" file created from a ".ewe" file.

Parameters:
extension - This is the file extension (e.g. ".pnf")
shortFileDescription - This is a mandatory short file description (e.g. "JewelFile");
fileDescription - This is an optional long file description (e.g. "Jewel Program Specs")
icon - The file name of an optional icon to associate with files of this extension.
Throws:
IOException - If an error occurs saving the registry information.

getEweCommandLine

public static String getEweCommandLine(String myEweFile,
                                       String extraArguments,
                                       String vmArguments,
                                       boolean includePathToVM)
                                throws IOException
Create an absolute command line to execute the Ewe VM on my Ewe file.

Parameters:
myEweFile - the name (without a path specification) of the Ewe file this application is packaged in. If it is null the VM will attempt to lookup the name of the currently running .ewe file.
extraArguments - Additional application arguments - can be null.
vmArguments - Additional VM arguments - can be null.
includePathToVM - Set this true to include the path to the Ewe VM.
Returns:
An absolute command line for executing the currently running application.
Throws:
IOException - if there is a problem with any of the data.

getEweCommandLineToMe

public static String getEweCommandLineToMe(String extraArguments,
                                           String vmArguments,
                                           boolean includePathToVM)
                                    throws IOException
Create an absolute command line to execute the Ewe VM on my Ewe file.

Parameters:
extraArguments - Additional application arguments - can be null.
vmArguments - Additional VM arguments - can be null.
includePathToVM - Set this true to include the path to the Ewe VM.
Returns:
An absolute command line for executing the currently running application.
Throws:
IOException - if there is a problem with any of the data.