registry.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:7k
- '"
- '" Copyright (c) 1997 Sun Microsystems, Inc.
- '" Copyright (c) 2002 ActiveState Corporation.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: registry.n,v 1.8.2.2 2004/11/12 09:02:30 das Exp $
- '"
- .so man.macros
- .TH registry n 1.1 registry "Tcl Bundled Packages"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- registry - Manipulate the Windows registry
- .SH SYNOPSIS
- .sp
- fBpackage require registry 1.1fR
- .sp
- fBregistry fIoptionfR fIkeyNamefR ?fIarg arg ...fR?
- .BE
- .SH DESCRIPTION
- .PP
- The fBregistryfR package provides a general set of operations for
- manipulating the Windows registry. The package implements the
- fBregistryfR Tcl command. This command is only supported on the
- Windows platform. Warning: this command should be used with caution
- as a corrupted registry can leave your system in an unusable state.
- .PP
- fIKeyNamefR is the name of a registry key. Registry keys must be
- one of the following forms:
- .IP
- fBeefIhostnamefBefIrootnamefBefIkeypathfR
- .IP
- fIrootnamefBefIkeypathfR
- .IP
- fIrootnamefR
- .PP
- fIHostnamefR specifies the name of any valid Windows
- host that exports its registry. The fIrootnamefR component must be
- one of fBHKEY_LOCAL_MACHINEfR, fBHKEY_USERSfR,
- .VS
- fBHKEY_CLASSES_ROOTfR, fBHKEY_CURRENT_USERfR,
- fBHKEY_CURRENT_CONFIGfR, fBHKEY_PERFORMANCE_DATAfR, or
- fBHKEY_DYN_DATAfR. The fIkeypathfR can be one or more
- .VE
- registry key names separated by backslash (fBefR) characters.
- .PP
- fIOptionfR indicates what to do with the registry key name. Any
- unique abbreviation for fIoptionfR is acceptable. The valid options
- are:
- .VS 8.4
- .TP
- fBregistry broadcast fIkeyNamefR ?fI-timeout millisecondsfR?
- .
- Sends a broadcast message to the system and running programs to notify them
- of certain updates. This is necessary to propagate changes to key registry
- keys like Environment. The timeout specifies the amount of time, in
- milliseconds, to wait for applications to respond to the broadcast message.
- It defaults to 3000. The following example demonstrates how to add a path
- to the global Environment and notify applications of the change without
- requiring a logoff/logon step (assumes admin privileges):
- .CS
- set regPath {HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment}
- set curPath [registry get $regPath "Path"]
- registry set $regPath "Path" "$curPath;$addPath"
- registry broadcast "Environment"
- .CE
- .VE 8.4
- .TP
- fBregistry delete fIkeyNamefR ?fIvalueNamefR?
- .
- If the optional fIvalueNamefR argument is present, the specified
- value under fIkeyNamefR will be deleted from the registry. If the
- optional fIvalueNamefR is omitted, the specified key and any subkeys
- or values beneath it in the registry hierarchy will be deleted. If
- the key could not be deleted then an error is generated. If the key
- did not exist, the command has no effect.
- .TP
- fBregistry get fIkeyName valueNamefR
- .
- Returns the data associated with the value fIvalueNamefR under the key
- fIkeyNamefR. If either the key or the value does not exist, then an
- error is generated. For more details on the format of the returned
- data, see SUPPORTED TYPES, below.
- .TP
- fBregistry keys fIkeyNamefR ?fIpatternfR?
- .
- If fIpatternfR isn't specified, returns a list of names of all the
- subkeys of fIkeyNamefR. If fIpatternfR is specified, only those
- names matching fIpatternfR are returned. Matching is determined
- using the same rules as for fBstringfR fBmatchfR. If the
- specified fIkeyNamefR does not exist, then an error is generated.
- .TP
- fBregistry set fIkeyNamefR ?fIvalueName data fR?fItypefR??
- .
- If fIvalueNamefR isn't specified, creates the key fIkeyNamefR if
- it doesn't already exist. If fIvalueNamefR is specified, creates
- the key fIkeyNamefR and value fIvalueNamefR if necessary. The
- contents of fIvalueNamefR are set to fIdatafR with the type
- indicated by fItypefR. If fItypefR isn't specified, the type
- fBszfR is assumed. For more details on the data and type arguments,
- see SUPPORTED TYPES below.
- .TP
- fBregistry type fIkeyName valueNamefR
- .
- Returns the type of the value fIvalueNamefR in the key
- fIkeyNamefR. For more information on the possible types, see
- SUPPORTED TYPES, below.
- .TP
- fBregistry values fIkeyNamefR ?fIpatternfR?
- .
- If fIpatternfR isn't specified, returns a list of names of all the
- values of fIkeyNamefR. If fIpatternfR is specified, only those
- names matching fIpatternfR are returned. Matching is determined
- using the same rules as for fBstringfR fBmatchfR.
- .SH "SUPPORTED TYPES"
- Each value under a key in the registry contains some data of a
- particular type in a type-specific representation. The fBregistryfR
- command converts between this internal representation and one that can
- be manipulated by Tcl scripts. In most cases, the data is simply
- returned as a Tcl string. The type indicates the intended use for the
- data, but does not actually change the representation. For some
- types, the fBregistryfR command returns the data in a different form to
- make it easier to manipulate. The following types are recognized by the
- registry command:
- .TP 17
- fBbinaryfR
- .
- The registry value contains arbitrary binary data. The data is represented
- exactly in Tcl, including any embedded nulls.
- .TP
- fBnonefR
- .
- The registry value contains arbitrary binary data with no defined
- type. The data is represented exactly in Tcl, including any embedded
- nulls.
- .TP
- fBszfR
- .
- The registry value contains a null-terminated string. The data is
- represented in Tcl as a string.
- .TP
- fBexpand_szfR
- .
- The registry value contains a null-terminated string that contains
- unexpanded references to environment variables in the normal Windows
- style (for example, "%PATH%"). The data is represented in Tcl as a
- string.
- .TP
- fBdwordfR
- .
- The registry value contains a little-endian 32-bit number. The data is
- represented in Tcl as a decimal string.
- .TP
- fBdword_big_endianfR
- .
- The registry value contains a big-endian 32-bit number. The data is
- represented in Tcl as a decimal string.
- .TP
- fBlinkfR
- .
- The registry value contains a symbolic link. The data is represented
- exactly in Tcl, including any embedded nulls.
- .TP
- fBmulti_szfR
- .
- The registry value contains an array of null-terminated strings. The
- data is represented in Tcl as a list of strings.
- .TP
- fBresource_listfR
- .
- The registry value contains a device-driver resource list. The data
- is represented exactly in Tcl, including any embedded nulls.
- .PP
- In addition to the symbolically named types listed above, unknown
- types are identified using a 32-bit integer that corresponds to the
- type code returned by the system interfaces. In this case, the data
- is represented exactly in Tcl, including any embedded nulls.
- .SH "PORTABILITY ISSUES"
- The registry command is only available on Windows.
- .SH EXAMPLE
- Print out how double-clicking on a Tcl script file will invoke a Tcl
- interpreter:
- .CS
- package require registry
- set ext .tcl
- # Read the type name
- set type [fBregistry getfR HKEY_CLASSES_ROOTee$ext {}]
- # Work out where to look for the command
- set path HKEY_CLASSES_ROOTee$typeeeShelleeOpeneecommand
- # Read the command!
- set command [fBregistry getfR $path {}]
- puts "$ext opens with $command"
- .CE
- .SH KEYWORDS
- registry