Reading the Windows registry

The Windows registry is a database used by the Windows
operating system to store configuration information. Often it becomes necessary for a tester to read
information out of this database using HCL OneTest™ UI commands.
This topic provides examples for doing this.

There are two commands available to read values from the registry. The
getRegistryValue command is used to read string values from the registry. The
getRegistryIntValue is used to read integer values from the registry. The terms
"REG_SZ" describe the string and integer types. Both of the commands take a type
String argument, which contains the registry key to extract.

Note: When entering keys, the "\" is a special character in Java™ and must be doubled to "\\" to be taken
as a literal.

The example extracts both a string and an integer value from the
registry. Looking first at the String value segment,
notice the core code:

The first line creates a type String variable, which contains the registry value
to extract. The second line executes the command and stores it in the type String
variable regValueString. The third line uses the
JOptionPane.showMessageDialog class to display the registry value in a message box
on the screen. For those unfamiliar with this last class, it is a Java Swing class, which must be
imported to be available. Note the last import statement at the top of the
script.

The second segment extracts the type int value.
In the example, the simple type int is converted
to an Integer object, so that it can be displayed
in the JOptionPane dialog. Otherwise, the code is
identical to the first segment.

Both of the commands throw a NoSuchRegistryKeyException when
they fail. Therefore, it is a good idea to wrap these methods within
a try/catch block, as in the example. You can change the registry
key to one that does not exist and run the script. You will see an
error message indicating the key could not be found.