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
44       abbreviation 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
51              applications to respond to the broadcast message.   It  defaults
52              to  3000.   The following example demonstrates how to add a path
53              to 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,
101              below.
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
117       manipulate.   The  following  types are recognized by the registry com‐
118       mand:
119
120       binary           The registry value  contains  arbitrary  binary  data.
121                        The  data is represented exactly in Tcl, including any
122                        embedded nulls.
123
124       none             The registry value contains arbitrary binary data with
125                        no  defined  type.  The data is represented exactly in
126                        Tcl, including any embedded nulls.
127
128       sz               The registry value contains a null-terminated  string.
129                        The data is represented in Tcl as a string.
130
131       expand_sz        The  registry  value contains a null-terminated string
132                        that contains  unexpanded  references  to  environment
133                        variables  in  the  normal Windows style (for example,
134                        “%PATH%”).  The  data  is  represented  in  Tcl  as  a
135                        string.
136
137       dword            The  registry  value  contains  a little-endian 32-bit
138                        number.  The data is represented in Tcl as  a  decimal
139                        string.
140
141       dword_big_endian The  registry  value contains a big-endian 32-bit num‐
142                        ber.  The data is represented  in  Tcl  as  a  decimal
143                        string.
144
145       link             The registry value contains a symbolic link.  The data
146                        is represented exactly in Tcl, including any  embedded
147                        nulls.
148
149       multi_sz         The  registry  value  contains an array of null-termi‐
150                        nated strings.  The data is represented in  Tcl  as  a
151                        list of strings.
152
153       resource_list    The  registry  value contains a device-driver resource
154                        list.  The data is represented exactly in Tcl, includ‐
155                        ing any embedded nulls.
156
157       In addition to the symbolically named types listed above, unknown types
158       are identified using a 32-bit integer that corresponds to the type code
159       returned  by  the  system interfaces.  In this case, the data is repre‐
160       sented exactly in Tcl, including any embedded nulls.
161

PORTABILITY ISSUES

163       The registry command is only available on Windows.
164

EXAMPLE

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

KEYWORDS

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