www.gibmonks.com




  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 9.  Working with Files and Programs


The registry Command

Windows uses the registry to store various system configuration information. The Windows tool to browse and edit the registry is called regedit. Tcl provides a registry command. It is a loadable package that you must load by using:

package require registry

The registry structure has keys, value names, and typed data. The value names are stored under a key, and each value name has data associated with it. The keys are organized into a hierarchical naming system, so another way to think of the value names is as an extra level in the hierarchy. The main point is that you need to specify both a key name and a value name in order to get something out of the registry. The key names have one of the following formats:

\\hostname\rootname\keypath
rootname\keypath
rootname

The rootname is one of HKEY_LOCAL_MACHINE, HKEY_PERFORMANCE_DATA, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, or HKEY_DYN_DATA. Tables 9-8 and 9-9 summarize the registry command and data types:

Table 9-8. The registry command.
registry delete key ?valueName?Deletes the key and the named value, or it deletes all values under the key if valueName is not specified.
registry get key valueNameReturns the value associated with valueName under key.
registry keys key ?pat?Returns the list of keys or value names under key that match pat, which is a string match pattern.
registry set keyCreates key.
registry set key valueName data ?type?Creates valueName under key with value data of the given type. Types are listed in Table 9-9.
registry type key valueNameReturns the type of valueName under key.
registry values key ?pat?Returns the names of the values stored under key that match pat, which is a string match pattern.

Table 9-9. The registry data types.
binaryArbitrary binary data.
noneArbitrary binary data.
expand_szA string that contains references to environment variables with the %VARNAME% syntax.
dwordA 32-bit integer.
dword_big_endianA 32-bit integer in the other byte order. It is represented in Tcl as a decimal string.
linkA symbolic link.
multi_szAn array of strings, which are represented as a Tcl list.
resource_listA device driver resource list.


      Previous section   Next section
    Top