[ Team LiB ] Previous Section Next Section

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-9 and 9-10 summarize the registry command and data types:

Table 9-9. 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 valueName

Returns 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 key

Creates key.

registry set key valueName data ?type?

Creates valueName under key with value data of the given type. Types are listed in Table 9-10.

registry type key valueName

Returns 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-10. The registry data types

binary

Arbitrary binary data.

none

Arbitrary binary data.

expand_sz

A string that contains references to environment variables with the %VARNAME% syntax.

dword

A 32-bit integer.

dword_big_endian

A 32-bit integer in the other byte order. It is represented in Tcl as a decimal string.

link

A symbolic link.

multi_sz

An array of strings, which are represented as a Tcl list.

resource_list

A device driver resource list.

    [ Team LiB ] Previous Section Next Section