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
16

DESCRIPTION

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

SUPPORTED TYPES

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

PORTABILITY ISSUES

152       The registry command is only available on Windows.
153

EXAMPLE

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

KEYWORDS

171       registry
172
173
174
175registry                              1.1                          registry(n)
Impressum