Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/registry.n @ 37

Last change on this file since 37 was 25, checked in by landauf, 16 years ago

added tcl to libs

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