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.1
12
13       registry 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       Option indicates what to do with the registry  key  name.   Any  unique
39       abbreviation for option is acceptable.  The valid options are:
40
41       registry broadcast keyName ?-timeout milliseconds?
42              Sends  a broadcast message to the system and running programs to
43              notify them of certain updates.  This is necessary to  propagate
44              changes  to  key  registry  keys  like Environment.  The timeout
45              specifies the amount of  time,  in  milliseconds,  to  wait  for
46              applications  to  respond to the broadcast message.  It defaults
47              to 3000.  The following example demonstrates how to add  a  path
48              to  the global Environment and notify applications of the change
49              without requiring a  logoff/logon  step  (assumes  admin  privi‐
50              leges):
51
52                     set regPath [join {
53                         HKEY_LOCAL_MACHINE
54                         SYSTEM
55                         CurrentControlSet
56                         Control
57                         {Session Manager}
58                         Environment
59                     } "\\"]
60                     set curPath [registry get $regPath "Path"]
61                     registry set $regPath "Path" "$curPath;$addPath"
62                     registry broadcast "Environment"
63
64       registry delete keyName ?valueName?
65              If  the  optional  valueName  argument is present, the specified
66              value under keyName will be deleted from the registry.   If  the
67              optional valueName is omitted, the specified key and any subkeys
68              or values beneath it in the registry hierarchy will be  deleted.
69              If  the key could not be deleted then an error is generated.  If
70              the key did not exist, the command has no effect.
71
72       registry get keyName valueName
73              Returns the data associated with the value valueName  under  the
74              key  keyName.   If  either  the key or the value does not exist,
75              then an error is generated.  For more details on the  format  of
76              the returned data, see SUPPORTED TYPES, below.
77
78       registry keys keyName ?pattern?
79              If  pattern is not specified, returns a list of names of all the
80              subkeys of keyName.  If pattern is specified, only  those  names
81              matching pattern are returned.  Matching is determined using the
82              same rules as for string match.  If the specified  keyName  does
83              not exist, then an error is generated.
84
85       registry set keyName ?valueName data ?type??
86              If  valueName  is  not  specified, creates the key keyName if it
87              does not already exist.  If valueName is specified, creates  the
88              key  keyName  and value valueName if necessary.  The contents of
89              valueName are set to data with the type indicated by  type.   If
90              type is not specified, the type sz is assumed.  For more details
91              on the data and type arguments, see SUPPORTED TYPES below.
92
93       registry type keyName valueName
94              Returns the type of the value valueName in the key keyName.  For
95              more  information  on  the  possible types, see SUPPORTED TYPES,
96              below.
97
98       registry values keyName ?pattern?
99              If pattern is not specified, returns a list of names of all  the
100              values  of  keyName.   If pattern is specified, only those names
101              matching pattern are returned.  Matching is determined using the
102              same rules as for string match.
103

SUPPORTED TYPES

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

PORTABILITY ISSUES

158       The registry command is only available on Windows.
159

EXAMPLE

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

KEYWORDS

177       registry
178
179
180
181registry                              1.1                          registry(n)
Impressum