<LI><A HREF="#exports [use and import()]">Exports [<A HREF="../../../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A> and <A HREF="../../../lib/Pod/perlfunc.html#item_import"><CODE>import()</CODE></A>]</A></LI>
<UL>
<LI><A HREF="#specifying constants in your perl code">Specifying constants in your Perl code</A></LI>
If the hash is tied to the virtual root of the registry [or the
virtual root of a remote machine's registry], then we treat hash
key strings which start with the delimiter character specially.
<P>If the hash key string starts with two delimiters in a row, then
those should be immediately followed by the name of a remote
machine whose registry we wish to connect to. That can be
followed by a delimiter and more subkey names, etc. If the
machine name is not following by anything, then a virtual root
for the remote machine's registry is created, a hash is tied to
it, and a reference to that hash it is returned.</P>
<P></P>
<DT><STRONG><A NAME="item_Hash_key_string_starts_with_the_delimiter">Hash key string starts with the delimiter</A></STRONG><BR>
<DD>
If the hash is tied to a virtual root key, then the leading
delimiter is ignored. It should be followed by a valid Registry
root key name [either a short-hand name like <CODE>"LMachine"</CODE>, an
<EM>HKEY_*</EM> value, or a numeric value]. This alternate notation is
allowed in order to be more consistant with the <A HREF="#item_Open"><CODE>Open()</CODE></A> method
function.
<P>For all other Registry keys, the leading delimiter indicates
that the rest of the string is a value name. The leading
delimiter is stripped and the rest of the string [which can
be empty and can contain more delimiters] is used as a value
name with no further parsing.</P>
<P></P>
<DT><STRONG><A NAME="item_Exact_match_with_direct_subkey_name_followed_by_de">Exact match with direct subkey name followed by delimiter</A></STRONG><BR>
<DD>
If you have already called the Perl <A HREF="../../../lib/Pod/perlfunc.html#item_keys"><CODE>keys</CODE></A> function on the tied
hash [or have already called <A HREF="#item_MemberNames"><CODE>MemberNames</CODE></A> on the object] and the
hash key string exactly matches one of the strings returned, then
no further parsing is done. In other words, if the key string
exactly matches the name of a direct subkey with a delimiter
appended, then a reference to a hash tied to that subkey is
returned [but only if <A HREF="../../../lib/Pod/perlfunc.html#item_keys"><CODE>keys</CODE></A> or <A HREF="#item_MemberNames"><CODE>MemberNames</CODE></A> has already
been called for that tied hash].
<P>This is only important if you have selected a delimiter other than
the system default delimiter and one of the subkey names contains
the delimiter you have chosen. This rule allows you to deal with
subkeys which contain your chosen delimiter in their name as long
as you only traverse subkeys one level at a time and always
enumerate the list of members before doing so.</P>
<P>The main advantage of this is that Perl code which recursively
traverses a hash will work on hashes tied to Registry keys even if
a non-default delimiter has been selected.</P>
<P></P>
<DT><STRONG><A NAME="item_Hash_key_string_contains_two_delimiters_in_a_row">Hash key string contains two delimiters in a row</A></STRONG><BR>
<DD>
If the hash key string contains two [or more] delimiters in a row,
then the string is split between the first pair of delimiters.
The first part is interpreted as a subkey name or a path of subkey
names separated by delimiters and with a trailing delimiter. The
second part is interpreted as a value name with one leading
delimiter [any extra delimiters are considered part of the value
name].
<P></P>
<DT><STRONG><A NAME="item_Hash_key_string_ends_with_a_delimiter">Hash key string ends with a delimiter</A></STRONG><BR>
<DD>
If the key string ends with a delimiter, then it is treated
as a subkey name or path of subkey names separated by delimiters.
<P></P>
<DT><STRONG><A NAME="item_Hash_key_string_contains_a_delimiter">Hash key string contains a delimiter</A></STRONG><BR>
<DD>
If the key string contains a delimiter, then it is split after
the last delimiter. The first part is treated as a subkey name or
path of subkey names separated by delimiters. The second part
is ambiguous and is treated as outlined in the next item.
<P></P>
<DT><STRONG><A NAME="item_Hash_key_string_contains_no_delimiters">Hash key string contains no delimiters</A></STRONG><BR>
<DD>
If the hash key string contains no delimiters, then it is ambiguous.
<P>If you are reading from the hash [fetching], then we first use the
key string as a value name. If there is a value with a matching
name in the Registry key which the hash is tied to, then the value
data string [and possibly the value data type] is returned.
Otherwise, we retry by using the hash key string as a subkey name.
If there is a subkey with a matching name, then we return a
reference to a hash tied to that subkey. Otherwise we return
The <A HREF="#item_new"><CODE>new</CODE></A> method creates a new <EM>Win32::TieRegistry</EM> object.
<A HREF="#item_new"><CODE>new</CODE></A> is mostly a synonym for <A HREF="#item_Open"><CODE>Open()</CODE></A> so see <A HREF="#item_Open"><CODE>Open()</CODE></A> below for
information on what arguments to pass in. Examples:
<PRE>
$machKey= new Win32::TieRegistry "LMachine"
or die "Can't access HKEY_LOCAL_MACHINE key: $^E\n";
$userKey= Win32::TieRegistry->new("CUser")
or die "Can't access HKEY_CURRENT_USER key: $^E\n";</PRE>
<P>Note that calling <A HREF="#item_new"><CODE>new</CODE></A> via a reference to a tied hash returns
a simple object, not a reference to a tied hash.</P>
Enables or disables the <CODE>"ReRestorePrivilege"</CODE> privilege for the
current process. You will probably have to enable this privilege
before you can use <CODE>RegLoadKey()</CODE>, <CODE>RegUnLoadKey()</CODE>,
<CODE>RegReplaceKey()</CODE>, or <CODE>RegRestoreKey</CODE> and thus <A HREF="#item_Load"><CODE>Load()</CODE></A> and
<A HREF="#item_UnLoad"><CODE>UnLoad()</CODE></A>.
<P>The return value indicates whether the operation succeeded, not
whether the privilege was previously enabled.</P>
<P></P></DL>
<P>
<H2><A NAME="exports [use and import()]">Exports [<A HREF="../../../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A> and <A HREF="../../../lib/Pod/perlfunc.html#item_import"><CODE>import()</CODE></A>]</A></H2>
<P>To have nothing imported into your package, use something like:</P>
<PRE>
use Win32::TieRegistry 0.20 ();</PRE>
<P>which would verify that you have at least version 0.20 but wouldn't
call <A HREF="../../../lib/Pod/perlfunc.html#item_import"><CODE>import()</CODE></A>. The <EM>Changes</EM> file can be useful in figuring out
which, if any, prior versions of <EM>Win32::TieRegistry</EM> you want to
support in your script.</P>
<P>The code</P>
<PRE>
use Win32::TieRegistry;</PRE>
<P>imports the variable <CODE>$Registry</CODE> into your package and sets it
to be a reference to a hash tied to a copy of the master Registry
virtual root object with the default options. One disadvantage
to this ``default'' usage is that Perl does not support checking
the module version when you use it.</P>
<P>Alternately, you can specify a list of arguments on the <A HREF="../../../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A>
line that will be passed to the <CODE>Win32::TieRegistry-</CODE>import()>
method to control what items to import into your package. These
arguments fall into the following broad categories:</P>
<DL>
<DT><STRONG><A NAME="item_Import_a_reference_to_a_hash_tied_to_a_Registry_vi">Import a reference to a hash tied to a Registry virtual root</A></STRONG><BR>
<DD>
You can request that a scalar variable be imported (possibly)
and set to be a reference to a hash tied to a Registry virtual root
using any of the following types of arguments or argument pairs:
Allow the user to have unchecked calls (calls in a ``void context'')
to automatically report errors via <A HREF="../../../lib/Pod/perlfunc.html#item_warn"><CODE>warn</CODE></A> or <A HREF="../../../lib/Pod/perlfunc.html#item_die"><CODE>die</CODE></A>.
<P>For complex operations, such a copying an entire subtree, provide
access to detailed information about errors (and perhaps some
warnings) that were encountered. Let the user control whether
the complex operation continues in spite of errors.</P>