Debian Codegraph @

doc/registry.n

raw
1 '\"
2 '\" Copyright (c) 1997 Sun Microsystems, Inc.
3 '\" Copyright (c) 2002 ActiveState Corporation.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH registry n 1.1 registry "Tcl Bundled Packages"
9 .so man.macros
10 .BS
11 '\" Note: do not modify the .SH NAME line immediately below!
12 .SH NAME
13 registry \- Manipulate the Windows registry
14 .SH SYNOPSIS
15 .sp
16 \fBpackage require registry 1.3\fR
17 .sp
18 \fBregistry \fR?\fI\-mode\fR? \fIoption\fR \fIkeyName\fR ?\fIarg arg ...\fR?
19 .BE
20 .SH DESCRIPTION
21 .PP
22 The \fBregistry\fR package provides a general set of operations for
23 manipulating the Windows registry. The package implements the
24 \fBregistry\fR Tcl command. This command is only supported on the
25 Windows platform. Warning: this command should be used with caution
26 as a corrupted registry can leave your system in an unusable state.
27 .PP
28 \fIKeyName\fR is the name of a registry key. Registry keys must be
29 one of the following forms:
30 .RS
31 .PP
32 \fB\e\e\fIhostname\fB\e\fIrootname\fB\e\fIkeypath\fR
33 .PP
34 \fIrootname\fB\e\fIkeypath\fR
35 .PP
36 \fIrootname\fR
37 .RE
38 .PP
39 \fIHostname\fR specifies the name of any valid Windows
40 host that exports its registry. The \fIrootname\fR component must be
41 one of \fBHKEY_LOCAL_MACHINE\fR, \fBHKEY_USERS\fR,
42 \fBHKEY_CLASSES_ROOT\fR, \fBHKEY_CURRENT_USER\fR,
43 \fBHKEY_CURRENT_CONFIG\fR, \fBHKEY_PERFORMANCE_DATA\fR, or
44 \fBHKEY_DYN_DATA\fR. The \fIkeypath\fR can be one or more
45 registry key names separated by backslash (\fB\e\fR) characters.
46 .PP
47 .VS 8.6
48 The optional \fI\-mode\fR argument indicates which registry to work
49 with; when it is \fB\-32bit\fR the 32-bit registry will be used, and
50 when it is \fB\-64bit\fR the 64-bit registry will be used. If this
51 argument is omitted, the system's default registry will be the subject
52 of the requested operation.
53 .VE 8.6
54 .PP
55 \fIOption\fR indicates what to do with the registry key name. Any
56 unique abbreviation for \fIoption\fR is acceptable. The valid options
57 are:
58 .TP
59 \fBregistry broadcast \fIkeyName\fR ?\fB\-timeout \fImilliseconds\fR?
60 .
61 Sends a broadcast message to the system and running programs to notify them
62 of certain updates. This is necessary to propagate changes to key registry
63 keys like Environment. The timeout specifies the amount of time, in
64 milliseconds, to wait for applications to respond to the broadcast message.
65 It defaults to 3000. The following example demonstrates how to add a path
66 to the global Environment and notify applications of the change without
67 requiring a logoff/logon step (assumes admin privileges):
68 .RS
69 .PP
70 .CS
71 set regPath [join {
72 HKEY_LOCAL_MACHINE
73 SYSTEM
74 CurrentControlSet
75 Control
76 {Session Manager}
77 Environment
78 } "\e\e"]
79 set curPath [\fBregistry get\fR $regPath "Path"]
80 \fBregistry set\fR $regPath "Path" "$curPath;$addPath"
81 \fBregistry broadcast\fR "Environment"
82 .CE
83 .RE
84 .TP
85 \fBregistry delete \fIkeyName\fR ?\fIvalueName\fR?
86 .
87 If the optional \fIvalueName\fR argument is present, the specified
88 value under \fIkeyName\fR will be deleted from the registry. If the
89 optional \fIvalueName\fR is omitted, the specified key and any subkeys
90 or values beneath it in the registry hierarchy will be deleted. If
91 the key could not be deleted then an error is generated. If the key
92 did not exist, the command has no effect.
93 .TP
94 \fBregistry get \fIkeyName valueName\fR
95 .
96 Returns the data associated with the value \fIvalueName\fR under the key
97 \fIkeyName\fR. If either the key or the value does not exist, then an
98 error is generated. For more details on the format of the returned
99 data, see \fBSUPPORTED TYPES\fR, below.
100 .TP
101 \fBregistry keys \fIkeyName\fR ?\fIpattern\fR?
102 .
103 If \fIpattern\fR is not specified, returns a list of names of all the
104 subkeys of \fIkeyName\fR. If \fIpattern\fR is specified, only those
105 names matching \fIpattern\fR are returned. Matching is determined
106 using the same rules as for \fBstring match\fR. If the
107 specified \fIkeyName\fR does not exist, then an error is generated.
108 .TP
109 \fBregistry set \fIkeyName\fR ?\fIvalueName data \fR?\fItype\fR??
110 .
111 If \fIvalueName\fR is not specified, creates the key \fIkeyName\fR if
112 it does not already exist. If \fIvalueName\fR is specified, creates
113 the key \fIkeyName\fR and value \fIvalueName\fR if necessary. The
114 contents of \fIvalueName\fR are set to \fIdata\fR with the type
115 indicated by \fItype\fR. If \fItype\fR is not specified, the type
116 \fBsz\fR is assumed. For more details on the data and type arguments,
117 see \fBSUPPORTED TYPES\fR below.
118 .TP
119 \fBregistry type \fIkeyName valueName\fR
120 .
121 Returns the type of the value \fIvalueName\fR in the key
122 \fIkeyName\fR. For more information on the possible types, see
123 \fBSUPPORTED TYPES\fR, below.
124 .TP
125 \fBregistry values \fIkeyName\fR ?\fIpattern\fR?
126 .
127 If \fIpattern\fR is not specified, returns a list of names of all the
128 values of \fIkeyName\fR. If \fIpattern\fR is specified, only those
129 names matching \fIpattern\fR are returned. Matching is determined
130 using the same rules as for \fBstring match\fR.
131 .SH "SUPPORTED TYPES"
132 Each value under a key in the registry contains some data of a
133 particular type in a type-specific representation. The \fBregistry\fR
134 command converts between this internal representation and one that can
135 be manipulated by Tcl scripts. In most cases, the data is simply
136 returned as a Tcl string. The type indicates the intended use for the
137 data, but does not actually change the representation. For some
138 types, the \fBregistry\fR command returns the data in a different form to
139 make it easier to manipulate. The following types are recognized by the
140 registry command:
141 .TP 17
142 \fBbinary\fR
143 .
144 The registry value contains arbitrary binary data. The data is represented
145 exactly in Tcl, including any embedded nulls.
146 .TP
147 \fBnone\fR
148 .
149 The registry value contains arbitrary binary data with no defined
150 type. The data is represented exactly in Tcl, including any embedded
151 nulls.
152 .TP
153 \fBsz\fR
154 .
155 The registry value contains a null-terminated string. The data is
156 represented in Tcl as a string.
157 .TP
158 \fBexpand_sz\fR
159 .
160 The registry value contains a null-terminated string that contains
161 unexpanded references to environment variables in the normal Windows
162 style (for example,
163 .QW %PATH% ).
164 The data is represented in Tcl as a string.
165 .TP
166 \fBdword\fR
167 .
168 The registry value contains a little-endian 32-bit number. The data is
169 represented in Tcl as a decimal string.
170 .TP
171 \fBdword_big_endian\fR
172 .
173 The registry value contains a big-endian 32-bit number. The data is
174 represented in Tcl as a decimal string.
175 .TP
176 \fBlink\fR
177 .
178 The registry value contains a symbolic link. The data is represented
179 exactly in Tcl, including any embedded nulls.
180 .TP
181 \fBmulti_sz\fR
182 .
183 The registry value contains an array of null-terminated strings. The
184 data is represented in Tcl as a list of strings.
185 .TP
186 \fBresource_list\fR
187 .
188 The registry value contains a device-driver resource list. The data
189 is represented exactly in Tcl, including any embedded nulls.
190 .PP
191 In addition to the symbolically named types listed above, unknown
192 types are identified using a 32-bit integer that corresponds to the
193 type code returned by the system interfaces. In this case, the data
194 is represented exactly in Tcl, including any embedded nulls.
195 .SH "PORTABILITY ISSUES"
196 The registry command is only available on Windows.
197 .SH EXAMPLE
198 Print out how double-clicking on a Tcl script file will invoke a Tcl
199 interpreter:
200 .PP
201 .CS
202 package require registry
203 set ext .tcl
204
205 # Read the type name
206 set type [\fBregistry get\fR HKEY_CLASSES_ROOT\e\e$ext {}]
207 # Work out where to look for the command
208 set path HKEY_CLASSES_ROOT\e\e$type\e\eShell\e\eOpen\e\ecommand
209 # Read the command!
210 set command [\fBregistry get\fR $path {}]
211
212 puts "$ext opens with $command"
213 .CE
214 .SH KEYWORDS
215 registry
216 '\" Local Variables:
217 '\" mode: nroff
218 '\" End: