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