1registry(n)                  Tcl Bundled Packages                  registry(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       registry - Manipulate the Windows registry
9

SYNOPSIS

11       package require registry 1.3
12
13       registry ?-mode? option keyName ?arg arg ...?
14______________________________________________________________________________
15

DESCRIPTION

17       The  registry  package provides a general set of operations for manipu‐
18       lating the Windows registry.  The package implements the  registry  Tcl
19       command.   This  command  is  only  supported  on the Windows platform.
20       Warning: this command should be used with caution as a  corrupted  reg‐
21       istry can leave your system in an unusable state.
22
23       KeyName  is  the  name of a registry key.  Registry keys must be one of
24       the following forms:
25
26              \\hostname\rootname\keypath
27
28              rootname\keypath
29
30              rootname
31
32       Hostname specifies the name of any valid Windows host that exports  its
33       registry.   The  rootname  component must be one of HKEY_LOCAL_MACHINE,
34       HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER,  HKEY_CURRENT_CONFIG,
35       HKEY_PERFORMANCE_DATA,  or  HKEY_DYN_DATA.   The  keypath can be one or
36       more registry key names separated by backslash (\) characters.
37
38       The optional -mode argument indicates which registry to work with; when │
39       it  is  -32bit  the 32-bit registry will be used, and when it is -64bit 
40       the 64-bit registry will be used. If this argument is omitted, the sys‐ │
41       tem's default registry will be the subject of the requested operation.
42
43       Option indicates what to do with the registry key name.  Any unique ab‐
44       breviation for option is acceptable.  The valid options are:
45
46       registry broadcast keyName ?-timeout milliseconds?
47              Sends a broadcast message to the system and running programs  to
48              notify  them of certain updates.  This is necessary to propagate
49              changes to key registry  keys  like  Environment.   The  timeout
50              specifies  the  amount of time, in milliseconds, to wait for ap‐
51              plications to respond to the broadcast message.  It defaults  to
52              3000.   The  following example demonstrates how to add a path to
53              the global Environment and notify  applications  of  the  change
54              without  requiring  a  logoff/logon  step  (assumes admin privi‐
55              leges):
56
57                     set regPath [join {
58                         HKEY_LOCAL_MACHINE
59                         SYSTEM
60                         CurrentControlSet
61                         Control
62                         {Session Manager}
63                         Environment
64                     } "\\"]
65                     set curPath [registry get $regPath "Path"]
66                     registry set $regPath "Path" "$curPath;$addPath"
67                     registry broadcast "Environment"
68
69       registry delete keyName ?valueName?
70              If the optional valueName argument  is  present,  the  specified
71              value  under  keyName will be deleted from the registry.  If the
72              optional valueName is omitted, the specified key and any subkeys
73              or  values beneath it in the registry hierarchy will be deleted.
74              If the key could not be deleted then an error is generated.   If
75              the key did not exist, the command has no effect.
76
77       registry get keyName valueName
78              Returns  the  data associated with the value valueName under the
79              key keyName.  If either the key or the  value  does  not  exist,
80              then  an  error is generated.  For more details on the format of
81              the returned data, see SUPPORTED TYPES, below.
82
83       registry keys keyName ?pattern?
84              If pattern is not specified, returns a list of names of all  the
85              subkeys  of  keyName.  If pattern is specified, only those names
86              matching pattern are returned.  Matching is determined using the
87              same  rules  as for string match.  If the specified keyName does
88              not exist, then an error is generated.
89
90       registry set keyName ?valueName data ?type??
91              If valueName is not specified, creates the  key  keyName  if  it
92              does  not already exist.  If valueName is specified, creates the
93              key keyName and value valueName if necessary.  The  contents  of
94              valueName  are  set to data with the type indicated by type.  If
95              type is not specified, the type sz is assumed.  For more details
96              on the data and type arguments, see SUPPORTED TYPES below.
97
98       registry type keyName valueName
99              Returns the type of the value valueName in the key keyName.  For
100              more information on the possible types, see SUPPORTED TYPES, be‐
101              low.
102
103       registry values keyName ?pattern?
104              If  pattern is not specified, returns a list of names of all the
105              values of keyName.  If pattern is specified,  only  those  names
106              matching pattern are returned.  Matching is determined using the
107              same rules as for string match.
108

SUPPORTED TYPES

110       Each value under a key in the registry contains some data of a particu‐
111       lar  type in a type-specific representation.  The registry command con‐
112       verts between this internal representation and one that can be  manipu‐
113       lated  by Tcl scripts.  In most cases, the data is simply returned as a
114       Tcl string.  The type indicates the intended use for the data, but does
115       not  actually  change the representation.  For some types, the registry
116       command returns the data in a different form to make it easier  to  ma‐
117       nipulate.  The following types are recognized by the registry command:
118
119       binary           The  registry  value  contains  arbitrary binary data.
120                        The data is represented exactly in Tcl, including  any
121                        embedded nulls.
122
123       none             The registry value contains arbitrary binary data with
124                        no defined type.  The data is represented  exactly  in
125                        Tcl, including any embedded nulls.
126
127       sz               The  registry value contains a null-terminated string.
128                        The data is represented in Tcl as a string.
129
130       expand_sz        The registry value contains a  null-terminated  string
131                        that  contains  unexpanded  references  to environment
132                        variables in the normal Windows  style  (for  example,
133                        “%PATH%”).   The  data  is  represented  in  Tcl  as a
134                        string.
135
136       dword            The registry value  contains  a  little-endian  32-bit
137                        number.   The  data is represented in Tcl as a decimal
138                        string.
139
140       dword_big_endian The registry value contains a big-endian  32-bit  num‐
141                        ber.   The  data  is  represented  in Tcl as a decimal
142                        string.
143
144       link             The registry value contains a symbolic link.  The data
145                        is  represented exactly in Tcl, including any embedded
146                        nulls.
147
148       multi_sz         The registry value contains an  array  of  null-termi‐
149                        nated  strings.   The  data is represented in Tcl as a
150                        list of strings.
151
152       resource_list    The registry value contains a  device-driver  resource
153                        list.  The data is represented exactly in Tcl, includ‐
154                        ing any embedded nulls.
155
156       In addition to the symbolically named types listed above, unknown types
157       are identified using a 32-bit integer that corresponds to the type code
158       returned by the system interfaces.  In this case, the  data  is  repre‐
159       sented exactly in Tcl, including any embedded nulls.
160

PORTABILITY ISSUES

162       The registry command is only available on Windows.
163

EXAMPLE

165       Print  out  how  double-clicking on a Tcl script file will invoke a Tcl
166       interpreter:
167
168              package require registry
169              set ext .tcl
170
171              # Read the type name
172              set type [registry get HKEY_CLASSES_ROOT\\$ext {}]
173              # Work out where to look for the command
174              set path HKEY_CLASSES_ROOT\\$type\\Shell\\Open\\command
175              # Read the command!
176              set command [registry get $path {}]
177
178              puts "$ext opens with $command"
179

KEYWORDS

181       registry
182
183
184
185registry                              1.1                          registry(n)
Impressum