home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _2f3fd38e83eef96ea903eaf343a06959 < prev    next >
Encoding:
Text File  |  2004-06-01  |  60.8 KB  |  1,767 lines

  1. # Registry.pm -- Low-level access to functions/constants from WINREG.h
  2.  
  3. package Win32API::Registry;
  4.  
  5. use strict;
  6. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); #@EXPORT_FAIL);
  7. $VERSION= '0.22';
  8.  
  9. require Exporter;
  10. require DynaLoader;
  11. @ISA= qw(Exporter DynaLoader);
  12.  
  13. @EXPORT= qw();
  14. %EXPORT_TAGS= (
  15.     Func =>    [qw(        regConstant        regLastError
  16.         AllowPriv        AbortSystemShutdown    InitiateSystemShutdown
  17.     RegCloseKey        RegConnectRegistry    RegCreateKey
  18.     RegCreateKeyEx        RegDeleteKey        RegDeleteValue
  19.     RegEnumKey        RegEnumKeyEx        RegEnumValue
  20.     RegFlushKey        RegGetKeySecurity    RegLoadKey
  21.     RegNotifyChangeKeyValue    RegOpenKey        RegOpenKeyEx
  22.     RegQueryInfoKey        RegQueryMultipleValues    RegQueryValue
  23.     RegQueryValueEx        RegReplaceKey        RegRestoreKey
  24.     RegSaveKey        RegSetKeySecurity    RegSetValue
  25.     RegSetValueEx        RegUnLoadKey )],
  26.     FuncA =>    [qw(
  27.     AbortSystemShutdownA    InitiateSystemShutdownA
  28.     RegConnectRegistryA    RegCreateKeyA        RegCreateKeyExA
  29.     RegDeleteKeyA        RegDeleteValueA        RegEnumKeyA
  30.     RegEnumKeyExA        RegEnumValueA        RegLoadKeyA
  31.     RegOpenKeyA        RegOpenKeyExA        RegQueryInfoKeyA
  32.     RegQueryMultipleValuesA    RegQueryValueA        RegQueryValueExA
  33.     RegReplaceKeyA        RegRestoreKeyA        RegSaveKeyA
  34.     RegSetValueA        RegSetValueExA        RegUnLoadKeyA )],
  35.     FuncW =>    [qw(
  36.     AbortSystemShutdownW    InitiateSystemShutdownW
  37.     RegConnectRegistryW    RegCreateKeyW        RegCreateKeyExW
  38.     RegDeleteKeyW        RegDeleteValueW        RegEnumKeyW
  39.     RegEnumKeyExW        RegEnumValueW        RegLoadKeyW
  40.     RegOpenKeyW        RegOpenKeyExW        RegQueryInfoKeyW
  41.     RegQueryMultipleValuesW    RegQueryValueW        RegQueryValueExW
  42.     RegReplaceKeyW        RegRestoreKeyW        RegSaveKeyW
  43.     RegSetValueW        RegSetValueExW        RegUnLoadKeyW )],
  44.     HKEY_ =>    [qw(
  45.     HKEY_CLASSES_ROOT    HKEY_CURRENT_CONFIG    HKEY_CURRENT_USER
  46.     HKEY_DYN_DATA        HKEY_LOCAL_MACHINE    HKEY_PERFORMANCE_DATA
  47.     HKEY_USERS )],
  48.     KEY_ =>    [qw(
  49.     KEY_QUERY_VALUE        KEY_SET_VALUE        KEY_CREATE_SUB_KEY
  50.     KEY_ENUMERATE_SUB_KEYS    KEY_NOTIFY        KEY_CREATE_LINK
  51.     KEY_READ        KEY_WRITE        KEY_EXECUTE
  52.     KEY_ALL_ACCESS )],
  53.     REG_ =>    [qw(
  54.     REG_OPTION_RESERVED    REG_OPTION_NON_VOLATILE    REG_OPTION_VOLATILE
  55.     REG_OPTION_CREATE_LINK    REG_OPTION_BACKUP_RESTORE
  56.     REG_OPTION_OPEN_LINK    REG_LEGAL_OPTION    REG_CREATED_NEW_KEY
  57.     REG_OPENED_EXISTING_KEY    REG_WHOLE_HIVE_VOLATILE    REG_REFRESH_HIVE
  58.     REG_NO_LAZY_FLUSH    REG_NOTIFY_CHANGE_ATTRIBUTES
  59.     REG_NOTIFY_CHANGE_NAME    REG_NOTIFY_CHANGE_LAST_SET
  60.     REG_NOTIFY_CHANGE_SECURITY            REG_LEGAL_CHANGE_FILTER
  61.     REG_NONE        REG_SZ            REG_EXPAND_SZ
  62.     REG_BINARY        REG_DWORD        REG_DWORD_LITTLE_ENDIAN
  63.     REG_DWORD_BIG_ENDIAN    REG_LINK        REG_MULTI_SZ
  64.     REG_RESOURCE_LIST    REG_FULL_RESOURCE_DESCRIPTOR
  65.     REG_RESOURCE_REQUIREMENTS_LIST )],
  66.     SE_ =>    [qw(
  67.     SE_ASSIGNPRIMARYTOKEN_NAME    SE_AUDIT_NAME
  68.     SE_BACKUP_NAME            SE_CHANGE_NOTIFY_NAME
  69.     SE_CREATE_PAGEFILE_NAME        SE_CREATE_PERMANENT_NAME
  70.     SE_CREATE_TOKEN_NAME        SE_DEBUG_NAME
  71.     SE_INCREASE_QUOTA_NAME        SE_INC_BASE_PRIORITY_NAME
  72.     SE_LOAD_DRIVER_NAME        SE_LOCK_MEMORY_NAME
  73.     SE_MACHINE_ACCOUNT_NAME        SE_PROF_SINGLE_PROCESS_NAME
  74.     SE_REMOTE_SHUTDOWN_NAME        SE_RESTORE_NAME
  75.     SE_SECURITY_NAME        SE_SHUTDOWN_NAME
  76.     SE_SYSTEMTIME_NAME        SE_SYSTEM_ENVIRONMENT_NAME
  77.     SE_SYSTEM_PROFILE_NAME        SE_TAKE_OWNERSHIP_NAME
  78.     SE_TCB_NAME            SE_UNSOLICITED_INPUT_NAME )],
  79. );
  80. @EXPORT_OK= ();
  81. { my $ref;
  82.     foreach $ref (  values(%EXPORT_TAGS)  ) {
  83.     push( @EXPORT_OK, @$ref )   unless  $ref->[0] =~ /^SE_/;
  84.     }
  85. }
  86. $EXPORT_TAGS{ALL}= [ @EXPORT_OK ];    # \@EXPORT_OK once SE_* settles down.
  87. # push( @EXPORT_OK, "JHEREG_TACOSALAD" );    # Used to test Mkconst2perl
  88. push( @EXPORT_OK, @{$EXPORT_TAGS{SE_}} );
  89.  
  90. bootstrap Win32API::Registry $VERSION;
  91.  
  92. # Preloaded methods go here.
  93.  
  94. # To convert C constants to Perl code in cRegistry.pc
  95. # [instead of C or C++ code in cRegistry.h]:
  96. #    * Modify F<Makefile.PL> to add WriteMakeFile() =>
  97. #      CONST2PERL/postamble => [[ "Win32API::Registry" => ]] WRITE_PERL => 1.
  98. #    * Either comment out C<#include "cRegistry.h"> from F<Registry.xs>
  99. #      or make F<cRegistry.h> an empty file.
  100. #    * Make sure the following C<if> block is not commented out.
  101. #    * "nmake clean", "perl Makefile.PL", "nmake"
  102.  
  103. if(  ! defined ®_NONE  ) {
  104.     require "Win32API/Registry/cRegistry.pc";
  105. }
  106.  
  107. # This would be convenient but inconsistant and hard to explain:
  108. #push( @{$EXPORT_TAGS{ALL}}, @{$EXPORT_TAGS{SE_}} )
  109. #  if  defined &SE_TCB_NAME;
  110.  
  111. sub regConstant
  112. {
  113.     my( $name )= @_;
  114.     if(  1 != @_  ||  ! $name  ||  $name =~ /\W/  ) {
  115.     require Carp;
  116.     Carp::croak( 'Usage: ',__PACKAGE__,'::regConstant("CONST_NAME")' );
  117.     }
  118.     my $proto= prototype $name;
  119.     if(  defined \&$name
  120.      &&  defined $proto
  121.      &&  "" eq $proto  ) {
  122.     no strict 'refs';
  123.     return &$name;
  124.     }
  125.     return undef;
  126. }
  127.  
  128. # We provide this for backwards compatibility:
  129. sub constant
  130. {
  131.     my( $name )= @_;
  132.     my $value= regConstant( $name );
  133.     if(  defined $value  ) {
  134.     $!= 0;
  135.     return $value;
  136.     }
  137.     $!= 11; # EINVAL
  138.     return 0;
  139. }
  140.  
  141. BEGIN {
  142.     my $code= 'return _regLastError(@_)';
  143.     local( $!, $^E )= ( 1, 1 );
  144.     if(  $! ne $^E  ) {
  145.     $code= '
  146.         local( $^E )= _regLastError(@_);
  147.         my $ret= $^E;
  148.         return $ret;
  149.     ';
  150.     }
  151.     eval "sub regLastError { $code }";
  152.     die "$@"   if  $@;
  153. }
  154.  
  155. # Since we ISA DynaLoader which ISA AutoLoader, we ISA AutoLoader so we
  156. # need this next chunk to prevent Win32API::Registry->nonesuch() from
  157. # looking for "nonesuch.al" and producing confusing error messages:
  158. use vars qw($AUTOLOAD);
  159. sub AUTOLOAD {
  160.     require Carp;
  161.     Carp::croak(
  162.       "Can't locate method $AUTOLOAD via package Win32API::Registry" );
  163. }
  164.  
  165. # Replace "&rout;" with "goto &rout;" when that is supported on Win32.
  166.  
  167. # Let user omit all buffer sizes:
  168. sub RegEnumKeyExA {
  169.     if(  6 == @_  ) {    splice(@_,4,0,[]);  splice(@_,2,0,[]);  }
  170.     &_RegEnumKeyExA;
  171. }
  172. sub RegEnumKeyExW {
  173.     if(  6 == @_  ) {    splice(@_,4,0,[]);  splice(@_,2,0,[]);  }
  174.     &_RegEnumKeyExW;
  175. }
  176. sub RegEnumValueA {
  177.     if(  6 == @_  ) {    splice(@_,2,0,[]);  push(@_,[]);  }
  178.     &_RegEnumValueA;
  179. }
  180. sub RegEnumValueW {
  181.     if(  6 == @_  ) {    splice(@_,2,0,[]);  push(@_,[]);  }
  182.     &_RegEnumValueW;
  183. }
  184. sub RegQueryInfoKeyA {
  185.     if(  11 == @_  ) {    splice(@_,2,0,[]);  }
  186.     &_RegQueryInfoKeyA;
  187. }
  188. sub RegQueryInfoKeyW {
  189.     if(  11 == @_  ) {    splice(@_,2,0,[]);  }
  190.     &_RegQueryInfoKeyW;
  191. }
  192.  
  193. sub RegEnumKeyA {
  194.     push(@_,[])   if  3 == @_;
  195.     &_RegEnumKeyA;
  196. }
  197. sub RegEnumKeyW {
  198.     push(@_,[])   if  3 == @_;
  199.     &_RegEnumKeyW;
  200. }
  201. sub RegGetKeySecurity {
  202.     push(@_,[])   if  3 == @_;
  203.     &_RegGetKeySecurity;
  204. }
  205. sub RegQueryMultipleValuesA {
  206.     push(@_,[])   if  4 == @_;
  207.     &_RegQueryMultipleValuesA;
  208. }
  209. sub RegQueryMultipleValuesW {
  210.     push(@_,[])   if  4 == @_;
  211.     &_RegQueryMultipleValuesW;
  212. }
  213. sub RegQueryValueA {
  214.     push(@_,[])   if  3 == @_;
  215.     &_RegQueryValueA;
  216. }
  217. sub RegQueryValueW {
  218.     push(@_,[])   if  3 == @_;
  219.     &_RegQueryValueW;
  220. }
  221. sub RegQueryValueExA {
  222.     push(@_,[])   if  5 == @_;
  223.     &_RegQueryValueExA;
  224. }
  225. sub RegQueryValueExW {
  226.     push(@_,[])   if  5 == @_;
  227.     &_RegQueryValueExW;
  228. }
  229. sub RegSetValueA {
  230.     push(@_,0)   if  4 == @_;
  231.     &_RegSetValueA;
  232. }
  233. sub RegSetValueW {
  234.     push(@_,0)   if  4 == @_;
  235.     &_RegSetValueW;
  236. }
  237. sub RegSetValueExA {
  238.     push(@_,0)   if  5 == @_;
  239.     &_RegSetValueExA;
  240. }
  241. sub RegSetValueExW {
  242.     push(@_,0)   if  5 == @_;
  243.     &_RegSetValueExW;
  244. }
  245.  
  246. # Aliases for non-Unicode functions:
  247. sub AbortSystemShutdown        { &AbortSystemShutdownA; }
  248. sub InitiateSystemShutdown    { &InitiateSystemShutdownA; }
  249. sub RegConnectRegistry        { &RegConnectRegistryA; }
  250. sub RegCreateKey        { &RegCreateKeyA; }
  251. sub RegCreateKeyEx        { &RegCreateKeyExA; }
  252. sub RegDeleteKey        { &RegDeleteKeyA; }
  253. sub RegDeleteValue        { &RegDeleteValueA; }
  254. sub RegEnumKey            { &RegEnumKeyA; }
  255. sub RegEnumKeyEx        { &RegEnumKeyExA; }
  256. sub RegEnumValue        { &RegEnumValueA; }
  257. sub RegLoadKey            { &RegLoadKeyA; }
  258. sub RegOpenKey            { &RegOpenKeyA; }
  259. sub RegOpenKeyEx        { &RegOpenKeyExA; }
  260. sub RegQueryInfoKey        { &RegQueryInfoKeyA; }
  261. sub RegQueryMultipleValues    { &RegQueryMultipleValuesA; }
  262. sub RegQueryValue        { &RegQueryValueA; }
  263. sub RegQueryValueEx        { &RegQueryValueExA; }
  264. sub RegReplaceKey        { &RegReplaceKeyA; }
  265. sub RegRestoreKey        { &RegRestoreKeyA; }
  266. sub RegSaveKey            { &RegSaveKeyA; }
  267. sub RegSetValue            { &RegSetValueA; }
  268. sub RegSetValueEx        { &RegSetValueExA; }
  269. sub RegUnLoadKey        { &RegUnLoadKeyA; }
  270.  
  271. 1;
  272. __END__
  273.  
  274. =head1 NAME
  275.  
  276. Win32API::Registry - Low-level access to Win32 system API calls from WINREG.H
  277.  
  278. =head1 SYNOPSIS
  279.  
  280.   use Win32API::Registry 0.21 qw( :ALL );
  281.  
  282.   RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SYSTEM\\Disk", 0, KEY_READ, $key );
  283.     or  die "Can't open HKEY_LOCAL_MACHINE\\SYSTEM\\Disk: ",
  284.         regLastError(),"\n";
  285.   RegQueryValueEx( $key, "Information", [], $type, $data, [] );
  286.     or  die "Can't read HKEY_L*MACHINE\\SYSTEM\\Disk\\Information: ",
  287.         regLastError(),"\n";
  288.   [...]
  289.   RegCloseKey( $key )
  290.     or  die "Can't close HKEY_LOCAL_MACHINE\\SYSTEM\\Disk: ",
  291.         regLastError(),"\n";
  292.  
  293. =head1 DESCRIPTION
  294.  
  295. This provides fairly low-level access to the Win32 System API
  296. calls dealing with the Registry [mostly from WINREG.H].  This
  297. is mostly intended to be used by other modules such as
  298. C<Win32::TieRegistry> [which provides an extremely Perl-friendly
  299. method for using the Registry].
  300.  
  301. For a description of the logical structure of the Registry, see
  302. the documentation for the C<Win32::TieRegistry> module.
  303.  
  304. To pass in C<NULL> as the pointer to an optional buffer, pass in
  305. an empty list reference, C<[]>.
  306.  
  307. Beyond raw access to the API calls and related constants, this module
  308. handles smart buffer allocation and translation of return codes.
  309.  
  310. All calls return a true value for success and a false value for
  311. failure.  After any failure, C<$^E> should automatically be set
  312. to indicate the reason.  However, current versions of Perl often
  313. overwrite C<$^E> too quickly, so you can use C<regLastError()>
  314. instead, which is only set by Win32API::Registry routines. 
  315. C<regLastError()> is also good if you have a really old version
  316. of Perl that does not connect C<$^E> to C<GetLastError()> on
  317. Win32.
  318.  
  319. Note that C<$!> is not set by these routines except by
  320. C<Win32API::Registry::constant()> when a constant is not defined.
  321.  
  322. =head2 Exports
  323.  
  324. Nothing is exported by default.  The following tags can be used to
  325. have sets of symbols exported.
  326.  
  327. [Note that much of the following documentation refers to the
  328. behavior of the underlying API calls which may vary in current
  329. and future versions of the Win32 API without any changes to this
  330. module.  Therefore you should check the Win32 API documentation
  331. directly when needed.]
  332.  
  333. =over
  334.  
  335. =item :Func
  336.  
  337. The basic function names:
  338.  
  339. =over
  340.  
  341. =item AllowPriv
  342.  
  343. =item C<AllowPriv( $sPrivName, $bEnable )>
  344.  
  345. Not a Win32 API call.  Enables or disables a specific privilege for
  346. the current process.  Returns a true value if successful and a false
  347. value [and sets C<$^E>/C<regLastError()>] on failure.  This routine
  348. does not provide a way to tell if a privilege is currently enabled.
  349.  
  350. C<$sPrivname> is a Win32 privilege name [see L</:SE_>].  For example,
  351. C<"SeBackupPrivilege"> [a.k.a. C<SE_BACKUP_NAME>] controls whether
  352. you can use C<RegSaveKey()> and C<"SeRestorePrivilege"> [a.k.a.
  353. C<SE_RESTORE_NAME>] controls whether you can use C<RegLoadKey()>.
  354.  
  355. If C<$bEnable> is true, then C<AllowPriv()> tries to enable the
  356. privilege.  Otherwise it tries to disable the privilege.
  357.  
  358. =item AbortSystemShutdown
  359.  
  360. =item C<AbortSystemShutdown( $sComputerName )>
  361.  
  362. Tries to abort a remote shutdown request previously made via
  363. C<InitiateSystemShutdown()>.  Returns a true value if successful
  364. and a false value [and sets C<$^E>/C<regLastError()>] on failure.
  365.  
  366. =item InitiateSystemShutdown
  367.  
  368. =item C<InitiateSystemShutdown( $sComputer, $sMessage, $uTimeoutSecs, $bForce, $bReboot )>
  369.  
  370. Requests that a [remote] computer be shutdown or rebooted.
  371. Returns a true value if successful and a false value [and
  372. sets C<$^E>/C<regLastError()>] on failure.
  373.  
  374. C<$sComputer> is the name [or address] of the computer to be
  375. shutdown or rebooted.  You can use C<[]> [for C<NULL>] or C<"">
  376. to indicate the local computer.
  377.  
  378. C<$sMessage> is the message to be displayed in a pop-up window
  379. on the desktop of the computer to be shutdown or rebooted until
  380. the timeout expires or the shutdown is aborted via
  381. C<AbortSystemShutdown()>.  With C<$iTimeoutSecs == 0>, the
  382. message will never be visible.
  383.  
  384. C<$iTimeoutSecs> is the number of seconds to wait before starting
  385. the shutdown.
  386.  
  387. If C<$bForce> is false, then any applications running on the remote
  388. computer get a chance to prompt the remote user whether they want
  389. to save changes.  Also, for any applications that do not exit quickly
  390. enough, the operating system will prompt the user whether they wish
  391. to wait longer for the application to exit or force it to exit now.
  392. At any of these prompts the user can press B<CANCEL> to abort the
  393. shutdown but if no applications have unsaved data, they will likely
  394. all exit quickly and the shutdown will progress with the remote user
  395. having no option to cancel the shutdown.
  396.  
  397. If C<$bForce> is true, all applications are told to exit immediately
  398. and so will not prompt the user even if there is unsaved data.  Any
  399. applications that take too long to exit will be forcibly killed after
  400. a short time.  The only way to abort the shutdown is to call
  401. C<AbortSystemShutdown()> before the timeout expires and there is no
  402. way to abort the shutdown once it has begun.
  403.  
  404. If C<$bReboot> is true, the computer will automatically reboot once
  405. the shutdown is complete.  If C<$bReboot> is false, then when the
  406. shutdown is complete the computer will halt at a screen indicating
  407. that the shutdown is complete and offering a way for the user to
  408. start to boot the computer.
  409.  
  410. You must have the C<"SeRemoteShutdownPrivilege"> privilege
  411. on the remote computer for this call to succeed.  If shutting
  412. down the local computer, then the calling process must have
  413. the C<"SeShutdownPrivilege"> privilege and have it enabled.
  414.  
  415. =item RegCloseKey
  416.  
  417. =item C<RegCloseKey( $hKey )>
  418.  
  419. Closes the handle to a Registry key returned by C<RegOpenKeyEx()>,
  420. C<RegConnectRegistry()>, C<RegCreateKeyEx()>, or a few other
  421. routines.  Returns a true value if successful and a false value
  422. [and sets C<$^E>/C<regLastError()>] on failure.
  423.  
  424. =item RegConnectRegistry
  425.  
  426. =item C<RegConnectRegistry( $sComputer, $hRootKey, $ohKey )>
  427.  
  428. Connects to one of the root Registry keys of a remote computer.
  429. Returns a true value if successful and a false value [and
  430. sets C<$^E>/C<regLastError()>] on failure.
  431.  
  432. C<$sComputer> is the name [or address] of a remote computer
  433. whose Registry you wish to access.
  434.  
  435. C<$hKey> must be either C<HKEY_LOCAL_MACHINE> or C<HKEY_USERS>
  436. and specifies which root Registry key on the remote computer
  437. you wish to have access to.
  438.  
  439. C<$phKey> will be set to the handle to be used to access the
  440. remote Registry key if the call succeeds.
  441.  
  442. =item regConstant
  443.  
  444. =item C<$value= regConstant( $sConstantName )>
  445.  
  446. Fetch the value of a constant.  Returns C<undef> if C<$sConstantName>
  447. is not the name of a constant supported by this module.  Never sets
  448. C<$!> nor C<$^E>.
  449.  
  450. This function is rarely used since you will usually get the value of a
  451. constant by having that constant imported into your package by listing
  452. the constant name in the C<use Win32API::Registry> statement and then
  453. simply using the constant name in your code [perhaps followed by
  454. C<()>].  This function is useful for verifying constant names not in
  455. Perl code, for example, after prompting a user to type in a constant
  456. name.
  457.  
  458. =item RegCreateKey
  459.  
  460. =item C<RegCreateKey( $hKey, $sSubKey, $ohSubKey )>
  461.  
  462. This routine is meant only for compatibility with Windows version
  463. 3.1.  Use C<RegCreateKeyEx()> instead.
  464.  
  465. =item RegCreateKeyEx
  466.  
  467. =item C<RegCreateKeyEx( $hKey, $sSubKey, $uZero, $sClass, $uOpts, $uAccess, $pSecAttr, $ohNewKey, $ouDisp )>
  468.  
  469. Creates a new Registry subkey.  Returns a true value if successful and
  470. a false value [and sets C<$^E>/C<regLastError()>] on failure.
  471.  
  472. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  473. a previous call].
  474.  
  475. C<$sSubKey> is the name of the new subkey to be created.
  476.  
  477. C<$iZero> is reserved for future use and should always be specified
  478. as C<0>.
  479.  
  480. C<$sClass> is a string to be used as the class for the new
  481. subkey.  We are not aware of any current use for Registry key
  482. class information so the empty string, C<"">, should usually
  483. be used here.
  484.  
  485. C<$iOpts> is a numeric value containing bits that control options
  486. used while creating the new subkey.  C<REG_OPTION_NON_VOLATILE>
  487. is the default.  C<REG_OPTION_VOLATILE> [which is ignored on
  488. Windows 95] means the data stored under this key is not kept
  489. in a file and will not be preserved when the system reboots.
  490. C<REG_OPTION_BACKUP_RESTORE> [also ignored on Windows 95] means
  491. ignore the C<$iAccess> parameter and try to open the new key with
  492. the access required to backup or restore the key.
  493.  
  494. C<$iAccess> is a numeric mask of bits specifying what type of
  495. access is desired when opening the new subkey.  See C<RegOpenKeyEx()>.
  496.  
  497. C<$pSecAttr> is a C<SECURITY_ATTRIBUTES> structure packed into
  498. a Perl string which controls whether the returned handle can be
  499. inherited by child processes.  Normally you would pass C<[]> for
  500. this parameter to have C<NULL> passed to the underlying API
  501. indicating that the handle cannot be inherited.  If not under
  502. Windows95, then C<$pSecAttr> also allows you to specify
  503. C<SECURITY_DESCRIPTOR> that controls which users will have
  504. what type of access to the new key -- otherwise the new key
  505. inherits its security from its parent key.
  506.  
  507. C<$phKey> will be set to the handle to be used to access the new
  508. subkey if the call succeeds.
  509.  
  510. C<$piDisp> will be set to either C<REG_CREATED_NEW_KEY> or
  511. C<REG_OPENED_EXISTING_KEY> to indicate for which reason the
  512. call succeeded.  Can be specified as C<[]> if you don't care.
  513.  
  514. If C<$phKey> and C<$piDisp> start out as integers, then they will
  515. probably remain unchanged if the call fails.
  516.  
  517. =item RegDeleteKey
  518.  
  519. =item C<RegDeleteKey( $hKey, $sSubKey )>
  520.  
  521. Deletes a subkey of an open Registry key provided that the subkey
  522. contains no subkeys of its own [but the subkey may contain values].
  523. Returns a true value if successful and a false value [and sets
  524. C<$^E>/C<regLastError()>] on failure.
  525.  
  526. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  527. a previous call].
  528.  
  529. C<$sSubKey> is the name of the subkey to be deleted.
  530.  
  531. =item RegDeleteValue
  532.  
  533. =item C<RegDeleteValue( $hKey, $sValueName )>
  534.  
  535. Deletes a value from an open Registry key.  Returns a true value if
  536. successful and a false value [and sets C<$^E>/C<regLastError()>] on
  537. failure.
  538.  
  539. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  540. a previous call].
  541.  
  542. C<$sValueKey> is the name of the value to be deleted.
  543.  
  544. =item RegEnumKey
  545.  
  546. =item C<RegEnumKey( $hKey, $uIndex, $osName, $ilNameSize )>
  547.  
  548. This routine is meant only for compatibility with Windows version
  549. 3.1.  Use C<RegEnumKeyEx()> instead.
  550.  
  551. =item RegEnumKeyEx
  552.  
  553. =item C<RegEnumKeyEx( $hKey, $uIndex, $osName, $iolName, $pNull, $osClass, $iolClass, $opftLastWrite )>
  554.  
  555. Lets you enumerate the names of all of the subkeys directly under
  556. an open Registry key.  Returns a true value if successful and a false
  557. value [and sets C<$^E>/C<regLastError()>] on failure.
  558.  
  559. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  560. a previous call].
  561.  
  562. C<$iIndex> is the sequence number of the immediate subkey that
  563. you want information on.  Start with this value as C<0> then
  564. repeat the call incrementing this value each time until the
  565. call fails with C<$^E>/C<regLastError()> numerically equal to
  566. C<ERROR_NO_MORE_ITEMS>.
  567.  
  568. C<$sName> will be set to the name of the subkey.  Can be C<[]> if
  569. you don't care about the name.
  570.  
  571. C<$plName> initially specifies the [minimum] buffer size to be
  572. allocated for C<$sName>.  Will be set to the length of the subkey
  573. name if the requested subkey exists even if C<$sName> isn't
  574. successfully set to the subkey name.  See L<Buffer sizes> for
  575. more information.
  576.  
  577. C<$pNull> is reserved for future used and should be passed as C<[]>.
  578.  
  579. C<$sClass> will be set to the class name for the subkey.  Can be
  580. C<[]> if you don't care about the class.
  581.  
  582. C<$plClass> initially specifies the [minimum] buffer size to be
  583. allocated for C<$sClass> and will be set to the length of the
  584. subkey class name if the requested subkey exists.  See L<Buffer
  585. sizes> for more information.
  586.  
  587. C<$pftLastWrite> will be set to a C<FILETIME> structure packed
  588. into a Perl string and indicating when the subkey was last changed.
  589. Can be C<[]>.
  590.  
  591. You may omit both C<$plName> and C<$plClass> to get the same effect
  592. as passing in C<[]> for each of them.
  593.  
  594. =item RegEnumValue
  595.  
  596. =item C<RegEnumValue( $hKey, $uIndex, $osValName, $iolValName, $pNull, $ouType, $opValData, $iolValData )>
  597.  
  598. Lets you enumerate the names of all of the values contained in an
  599. open Registry key.  Returns a true value if successful and a false
  600. value [and sets C<$^E>/C<regLastError()>] on failure.
  601.  
  602. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  603. a previous call].
  604.  
  605. C<$iIndex> is the sequence number of the value that you want
  606. information on.  Start with this value as C<0> then repeat the
  607. call incrementing this value each time until the call fails with
  608. C<ERROR_NO_MORE_ITEMS>.
  609.  
  610. C<$sValName> will be set to the name of the value.  Can be C<[]>
  611. if you don't care about the name.
  612.  
  613. C<$plValName> initially specifies the [minimum] buffer size to be
  614. allocated for C<$sValName>.  Will be set to the length of the value
  615. name if the requested value exists even if C<$sValName> isn't
  616. successfully set to the value name.  See L<Buffer sizes> for
  617. more information.
  618.  
  619. C<$pNull> is reserved for future used and should be passed as C<[]>.
  620.  
  621. C<$piType> will be set to the type of data stored in the value data.
  622. If the call succeeds, it will be set to a C<REG_*> value unless
  623. passed in as C<[]>.
  624.  
  625. C<$pValData> will be set to the data [packed into a Perl string]
  626. that is stored in the requested value.  Can be C<[]> if you don't
  627. care about the value data.
  628.  
  629. C<$plValData> initially specifies the [minimum] buffer size to be
  630. allocated for C<$sValData> and will be set to the length of the
  631. value data if the requested value exists.  See L<Buffer sizes> for
  632. more information.
  633.  
  634. You may omit both C<$plValName> and C<$plValData> to get the same
  635. effect as passing in C<[]> for each of them.
  636.  
  637. =item RegFlushKey
  638.  
  639. =item C<RegFlushKey( $hKey )>
  640.  
  641. Forces the data stored under an open Registry key to be flushed
  642. to the disk file where the data is preserved between reboots.
  643. Forced flushing is not guaranteed to be efficient so this routine
  644. should almost never be called.  Returns a true value if successful
  645. and a false value [and sets C<$^E>/C<regLastError()>] on failure.
  646.  
  647. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  648. a previous call].
  649.  
  650. =item RegGetKeySecurity
  651.  
  652. =item C<RegGetKeySecurity( $hKey, $uSecInfo, $opSecDesc, $iolSecDesc )>
  653.  
  654. Retrieves one of the C<SECURITY_DESCRIPTOR> structures describing
  655. part of the security for an open Registry key.  Returns a true value
  656. if successful and a false value [and sets C<$^E>/C<regLastError()>]
  657. on failure.
  658.  
  659. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  660. a previous call].
  661.  
  662. C<$iSecInfo> is a numeric C<SECURITY_INFORMATION> value that
  663. specifies which parts of the C<SECURITY_DESCRIPTOR> structure
  664. to retrieve.  Should be C<OWNER_SECURITY_INFORMATION>,
  665. C<GROUP_SECURITY_INFORMATION>, C<DACL_SECURITY_INFORMATION>, or
  666. or C<SACL_SECURITY_INFORMATION> or two or more of these bits
  667. combined using C<|>.
  668.  
  669. C<$pSecDesc> will be set to the requested C<SECURITY_DESCRIPTOR>
  670. structure [packed into a Perl string].
  671.  
  672. C<$plSecDesc> initially specifies the [minimum] buffer size to be
  673. allocated for C<$sSecDesc> and will be set to the length of the
  674. security descriptor.  See L<Buffer sizes> for more information.
  675. You may omit this parameter to get the same effect as passing in
  676. C<[]> for it.
  677.  
  678. =item regLastError
  679.  
  680. =item C<$svError= regLastError();>
  681.  
  682. =item C<regLastError( $uError );>
  683.  
  684. Returns the last error encountered by a routine from this module. 
  685. It is just like C<$^E> except it isn't changed by anything except
  686. routines from this module.  Ideally you could just use C<$^E>, but
  687. current versions of Perl often overwrite C<$^E> before you get a
  688. chance to check it and really old versions of Perl don't really
  689. support C<$^E> under Win32.
  690.  
  691. Just like C<$^E>, in a numeric context C<regLastError()> returns
  692. the numeric error value while in a string context it returns a
  693. text description of the error [actually it returns a Perl scalar
  694. that contains both values so C<$x= regLastError()> causes C<$x>
  695. to give different values in string vs. numeric contexts].  On old
  696. versions of Perl where C<$^E> isn't tied to C<GetLastError()>,
  697. C<regLastError> simply returns the number of the error and you'll
  698. need to use <Win32::FormatMessage> to get the error string.
  699.  
  700. The last form sets the error returned by future calls to
  701. C<regLastError()> and should not be used often.  C<$uError> must
  702. be a numeric error code.  Also returns the dual-valued version
  703. of C<$uError>.
  704.  
  705. =item RegLoadKey
  706.  
  707. =item C<RegLoadKey( $hKey, $sSubKey, $sFileName )>
  708.  
  709. Loads a hive file.  That is, it creates a new subkey in the
  710. Registry and associates that subkey with a disk file that contains
  711. a Registry hive so that the new subkey can be used to access the
  712. keys and values stored in that hive.  Hives are usually created
  713. via C<RegSaveKey()>.  Returns a true value if successful and a
  714. false value [and sets C<$^E>/C<regLastError()>] on failure.
  715.  
  716. C<$hKey> is the handle to a Registry key that can have hives
  717. loaded to it.  This must be C<HKEY_LOCAL_MACHINE>, C<HKEY_USERS>,
  718. or a remote version of one of these from a call to
  719. C<RegConnectRegistry()>.
  720.  
  721. C<$sSubKey> is the name of the new subkey to created and associated
  722. with the hive file.
  723.  
  724. C<$sFileName> is the name of the hive file to be loaded.  This
  725. file name is interpretted relative to the
  726. C<%SystemRoot%/System32/config> directory on the computer where
  727. the C<$hKey> key resides.  If C<$sFileName> is on a FAT file
  728. system, then its name must not have an extension.
  729.  
  730. You must have the C<SE_RESTORE_NAME> privilege to use this routine.
  731.  
  732. WARNING:  Loading of hive files via a network share may silently
  733. corrupt the hive and so should not be attempted [this is a problem
  734. in at least some versions of the underlying API which this module
  735. does not try to fix or avoid].  To access a hive file located on a
  736. remote computer, connect to the remote computer's Registry and load
  737. the hive via that.
  738.  
  739. =item RegNotifyChangeKeyValue
  740.  
  741. =item C<RegNotifyChangeKeyValue( $hKey, $bWatchSubtree, $uNotifyFilter, $hEvent, $bAsync )>
  742.  
  743. Arranges for your process to be notified when part of the Registry
  744. is changed.  Returns a true value if successful and a false value
  745. [and sets C<$^E>/C<regLastError()>] on failure.
  746.  
  747. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  748. a previous call] for which you wish to be notified when any changes
  749. are made to it.
  750.  
  751. If C<$bWatchSubtree> is true, then changes to any subkey or
  752. descendant of C<$hKey> are also reported.
  753.  
  754. C<$iNotifyFilter> controllers what types of changes are reported.  It
  755. is a numeric value containing one or more of the following bit masks:
  756.  
  757. =over
  758.  
  759. =item C<REG_NOTIFY_CHANGE_NAME>
  760.  
  761. Notify if a subkey is added or deleted to a monitored key.
  762.  
  763. =item C<REG_NOTIFY_CHANGE_LAST_SET>
  764.  
  765. Notify if a value in a monitored key is added, deleted, or modified.
  766.  
  767. =item C<REG_NOTIFY_CHANGE_SECURITY>
  768.  
  769. Notify if a security descriptor of a monitored key is changed.
  770.  
  771. =item C<REG_NOTIFY_CHANGE_ATTRIBUTES>
  772.  
  773. Notify if any attributes of a monitored key are changed [class
  774. name or security descriptors].
  775.  
  776. =back
  777.  
  778. C<$hEvent> is ignored unless C<$bAsync> is true.  Otherwise, C<$hEvent>
  779. is a handle to a Win32 I<event> that will be signaled when changes are
  780. to be reported.
  781.  
  782. If C<$bAsync> is true, then C<RegNotifyChangeKeyValue()> returns
  783. immediately and uses C<$hEvent> to notify your process of changes.
  784. If C<$bAsync> is false, then C<RegNotifyChangeKeyValue()> does
  785. not return until there is a change to be notified of.
  786.  
  787. This routine does not work with Registry keys on remote computers.
  788.  
  789. =item RegOpenKey
  790.  
  791. =item C<RegOpenKey( $hKey, $sSubKey, $ohSubKey )>
  792.  
  793. This routine is meant only for compatibility with Windows version
  794. 3.1.  Use C<RegOpenKeyEx()> instead.
  795.  
  796. =item RegOpenKeyEx
  797.  
  798. =item C<RegOpenKeyEx( $hKey, $sSubKey, $uOptions, $uAccess, $ohSubKey )>
  799.  
  800. Opens an existing Registry key.  Returns a true value if successful
  801. and a false value [and sets C<$^E>/C<regLastError()>] on failure.
  802.  
  803. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  804. a previous call].
  805.  
  806. C<$sSubKey> is the name of an existing subkey to be opened.
  807. Can be C<""> or C<[]> to open an additional handle to the
  808. key specified by C<$hKey>.
  809.  
  810. C<$iOptions> is a numeric value containing bits that control options
  811. used while opening the subkey.  There are currently no supported
  812. options so this parameter should be specified as C<0>.
  813.  
  814. C<$iAccess> is a numeric mask of bits specifying what type of
  815. access is desired when opening the new subkey.  Should be a
  816. combination of one or more of the following bit masks:
  817.  
  818. =over
  819.  
  820. =item C<KEY_ALL_ACCESS>
  821.  
  822.     KEY_READ | KEY_WRITE | KEY_CREATE_LINK
  823.  
  824. =item C<KEY_READ>
  825.  
  826.     KEY_QUERY_VALUE | KEY_ENUMERATE_SUBKEYS | KEY_NOTIFY | STANDARD_RIGHTS_READ
  827.  
  828. =item C<KEY_WRITE>
  829.  
  830.     KEY_SET_VALUE | KEY_CREATE_SUB_KEY | STANDARD_RIGHTS_WRITE
  831.  
  832. =item C<KEY_QUERY_VALUE>
  833.  
  834. =item C<KEY_SET_VALUE>
  835.  
  836. =item C<KEY_ENUMERATE_SUB_KEYS>
  837.  
  838. =item C<KEY_CREATE_SUB_KEY>
  839.  
  840. =item C<KEY_NOTIFY>
  841.  
  842. Allows you to use C<RegNotifyChangeKeyValue()> on the opened key.
  843.  
  844. =item C<KEY_EXECUTE>
  845.  
  846. Same as C<KEY_READ>.
  847.  
  848. =item C<KEY_CREATE_LINK>
  849.  
  850. Gives you permission to create a symbolic link like
  851. C<HKEY_CLASSES_ROOT> and C<HKEY_CURRENT_USER>, though the method for
  852. doing so is not documented [and probably requires use of the mostly
  853. undocumented "native" routines, C<Nt*()> a.k.a. C<Zw*()>].
  854.  
  855. =back
  856.  
  857. C<$phKey> will be set to the handle to be used to access the new subkey
  858. if the call succeeds.
  859.  
  860. =item RegQueryInfoKey
  861.  
  862. =item C<RegQueryInfoKey( $hKey, $osClass, $iolClass, $pNull, $ocSubKeys, $olSubKey, $olSubClass, $ocValues, $olValName, $olValData, $olSecDesc, $opftTime )>
  863.  
  864. Gets miscellaneous information about an open Registry key.
  865. Returns a true value if successful and a false value [and
  866. sets C<$^E>/C<regLastError()>] on failure.
  867.  
  868. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  869. a previous call].
  870.  
  871. C<$sClass> will be set to the class name for the key.  Can be
  872. C<[]> if you don't care about the class.
  873.  
  874. C<$plClass> initially specifies the [minimum] buffer size to be
  875. allocated for C<$sClass> and will be set to the length of the
  876. key's class name.  See L<Buffer sizes> for more information.
  877. You may omit this parameter to get the same effect as passing in
  878. C<[]> for it.
  879.  
  880. C<$pNull> is reserved for future use and should be passed as C<[]>.
  881.  
  882. C<$pcSubKeys> will be set to the count of the number of subkeys
  883. directly under this key.  Can be C<[]>.
  884.  
  885. C<$plSubKey> will be set to the length of the longest subkey name.
  886. Can be C<[]>.
  887.  
  888. C<$plSubClass> will be set to the length of the longest class name
  889. used with an immediate subkey of this key.  Can be C<[]>.
  890.  
  891. C<$pcValues> will be set to the count of the number of values in
  892. this key.  Can be C<[]>.
  893.  
  894. C<$plValName> will be set to the length of the longest value name
  895. in this key.  Can be C<[]>.
  896.  
  897. C<$plValData> will be set to the length of the longest value data
  898. in this key.  Can be C<[]>.
  899.  
  900. C<$plSecDesc> will be set to the length of this key's full security
  901. descriptor.
  902.  
  903. C<$pftTime> will be set to a C<FILETIME> structure packed
  904. into a Perl string and indicating when this key was last changed.
  905. Can be C<[]>.
  906.  
  907. =item RegQueryMultipleValues
  908.  
  909. =item C<RegQueryMultipleValues( $hKey, $ioarValueEnts, $icValueEnts, $opBuffer, $iolBuffer )>
  910.  
  911. Allows you to use a single call to query several values from a single
  912. open Registry key to maximize efficiency.  Returns a true value if
  913. successful and a false value [and sets C<$^E>/C<regLastError()>] on
  914. failure.
  915.  
  916. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  917. a previous call].
  918.  
  919. C<$pValueEnts> should contain a list of C<VALENT> structures packed
  920. into a single Perl string.  Each C<VALENT> structure should have
  921. the C<ve_valuename> entry [the first 4 bytes] pointing to a string
  922. containing the name of a value stored in this key.  The remaining
  923. fields are set if the function succeeds.
  924.  
  925. C<$cValueEnts> should contain the count of the number of C<VALENT>
  926. structures contained in C<$pValueEnts>.
  927.  
  928. C<$pBuffer> will be set to the data from all of the requested values
  929. concatenated into a single Perl string.
  930.  
  931. C<$plBuffer> initially specifies the [minimum] buffer size to be
  932. allocated for C<$sBuffer> and will be set to the total length of
  933. the data to be written to C<$sBuffer>.  See L<Buffer sizes> for
  934. more information.  You may omit this parameter to get the same
  935. effect as passing in C<[]> for it.
  936.  
  937. Here is sample code to populate C<$pValueEnts>:
  938.  
  939.     # @ValueNames= ...list of value name strings...;
  940.     $cValueEnts= @ValueNames;
  941.     $pValueEnts= pack( " p x4 x4 x4 " x $cValueEnts, @ValueNames );
  942.  
  943. Here is sample code to retrieve the data type and data length
  944. returned in C<$pValueEnts>:
  945.  
  946.     @Lengths= unpack( " x4 L x4 x4 " x $cValueEnts, $pValueEnts );
  947.     @Types=   unpack( " x4 x4 x4 L " x $cValueEnts, $pValueEnts );
  948.  
  949. Given the above, and assuming you haven't modified C<$sBuffer> since
  950. the call, you can also extract the value data strings from C<$sBuffer>
  951. by using the pointers returned in C<$pValueEnts>:
  952.  
  953.     @Data=    unpack(  join( "", map {" x4 x4 P$_ x4 "} @Lengths ),
  954.             $pValueEnts  );
  955.  
  956. Much better is to use the lengths and extract directly from
  957. C<$sBuffer> using C<unpack()> [or C<substr()>]:
  958.  
  959.     @Data= unpack( join("",map("P$_",@Lengths)), $sBuffer );
  960.  
  961. =item RegQueryValue
  962.  
  963. =item C<RegQueryValue( $hKey, $sSubKey, $osValueData, $iolValueData )>
  964.  
  965. This routine is meant only for compatibility with Windows version
  966. 3.1.  Use C<RegQueryValueEx()> instead.  This routine can only
  967. query unamed values [a.k.a. "default values"], that is, values with
  968. a name of C<"">.
  969.  
  970. =item RegQueryValueEx
  971.  
  972. =item C<RegQueryValueEx( $hKey, $sValueName, $pNull, $ouType, $opValueData, $iolValueData )>
  973.  
  974. Lets you look up value data stored in an open Registry key by
  975. specifying the value name.  Returns a true value if successful
  976. and a false value [and sets C<$^E>/C<regLastError()>] on failure.
  977.  
  978. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  979. a previous call].
  980.  
  981. C<$sValueName> is the name of the value whose data you wish to
  982. retrieve.
  983.  
  984. C<$pNull> this parameter is reserved for future use and should be
  985. specified as C<[]>.
  986.  
  987. C<$piType> will be set to indicate what type of data is stored in
  988. the named value.  Will be set to a C<REG_*> value if the function
  989. succeeds.
  990.  
  991. C<$pValueData> will be set to the value data [packed into a Perl
  992. string] that is stored in the named value.  Can be C<[]> if you
  993. don't care about the value data.
  994.  
  995. C<$plValueData> initially specifies the [minimum] buffer size to be
  996. allocated for C<$sValueData> and will be set to the size [always
  997. in bytes] of the data to be written to C<$sValueData>, even if
  998. C<$sValueData> is not successfully written to.  See L<Buffer sizes>
  999. for more information.
  1000.  
  1001. =item RegReplaceKey
  1002.  
  1003. =item C<RegReplaceKey( $hKey, $sSubKey, $sNewFile, $sOldFile )>
  1004.  
  1005. Lets you replace an entire hive when the system is next booted. 
  1006. Returns a true value if successful and a false value [and sets
  1007. C<$^E>/C<regLastError()>] on failure.
  1008.  
  1009. C<$hKey> is the handle to a Registry key that has hive(s)
  1010. loaded in it.  This must be C<HKEY_LOCAL_MACHINE>,
  1011. C<HKEY_USERS>, or a remote version of one of these from
  1012. a call to C<RegConnectRegistry()>.
  1013.  
  1014. C<$sSubKey> is the name of the subkey of C<$hKey> whose hive
  1015. you wish to have replaced on the next reboot.
  1016.  
  1017. C<$sNewFile> is the name of a file that will replace the existing
  1018. hive file when the system reboots.
  1019.  
  1020. C<$sOldFile> is the file name to save the current hive file to
  1021. when the system reboots.
  1022.  
  1023. C<$sNewFile> and C<$sOldFile> are interpretted relative to the
  1024. C<%SystemRoot%/System32/config> directory on the computer where
  1025. the C<$hKey> key resides [I think].  If either file is [would be]
  1026. on a FAT file system, then its name must not have an extension.
  1027.  
  1028. You must have the C<SE_RESTORE_NAME> privilege to use this routine.
  1029.  
  1030. =item RegRestoreKey
  1031.  
  1032. =item C<RegRestoreKey( $hKey, $sFileName, $uFlags )>
  1033.  
  1034. Reads in a hive file and copies its contents over an existing
  1035. Registry tree.  Returns a true value if successful and a false
  1036. value [and sets C<$^E>/C<regLastError()>] on failure.
  1037.  
  1038. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  1039. a previous call].
  1040.  
  1041. C<$sFileName> is the name of the hive file to be read.  For each
  1042. value and subkey in this file, a value or subkey will be added
  1043. or replaced in C<$hKey>.
  1044.  
  1045. C<$uFlags> is usally C<0>.  It can also be C<REG_WHOLE_HIVE_VOLATILE>
  1046. which, rather than copying the hive over the existing key,
  1047. replaces the existing key with a temporary, memory-only Registry
  1048. key and then copies the hive contents into it.  This option only
  1049. works if C<$hKey> is C<HKEY_LOCAL_MACHINE>, C<HKEY_USERS>, or a
  1050. remote version of one of these from a call to C<RegConnectRegistry()>.
  1051.  
  1052. C<RegRestoreKey> does I<not> delete values nor keys from the
  1053. existing Registry tree when there is no corresponding value/key
  1054. in the hive file.
  1055.  
  1056. =item RegSaveKey
  1057.  
  1058. =item C<RegSaveKey( $hKey, $sFileName, $pSecAttr )>
  1059.  
  1060. Dumps any open Registry key and all of its subkeys and values into
  1061. a new hive file.  Returns a true value if successful and a false
  1062. value [and sets C<$^E>/C<regLastError()>] on failure.
  1063.  
  1064. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  1065. a previous call].
  1066.  
  1067. C<$sFileName> is the name of the file that the Registry tree
  1068. should be saved to.  It is interpretted relative to the
  1069. C<%SystemRoot%/System32/config> directory on the computer where
  1070. the C<$hKey> key resides.  If C<$sFileName> is on a FAT file system,
  1071. then it must not have an extension.
  1072.  
  1073. C<$pSecAttr> contains a C<SECURITY_ATTRIBUTES> structure that specifies
  1074. the permissions to be set on the new file that is created.  This can
  1075. be C<[]>.
  1076.  
  1077. You must have the C<SE_RESTORE_NAME> privilege to use this routine.
  1078.  
  1079. =item RegSetKeySecurity
  1080.  
  1081. =item C<RegSetKeySecurity( $hKey, $uSecInfo, $pSecDesc )>
  1082.  
  1083. Sets [part of] the C<SECURITY_DESCRIPTOR> structure describing part
  1084. of the security for an open Registry key.  Returns a true value if
  1085. successful and a false value [and sets C<$^E>/C<regLastError()>] on
  1086. failure.
  1087.  
  1088. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  1089. a previous call].
  1090.  
  1091. C<$uSecInfo> is a numeric C<SECURITY_INFORMATION> value that
  1092. specifies which C<SECURITY_DESCRIPTOR> structure to set.  Should
  1093. be C<OWNER_SECURITY_INFORMATION>, C<GROUP_SECURITY_INFORMATION>,
  1094. C<DACL_SECURITY_INFORMATION>, or C<SACL_SECURITY_INFORMATION>
  1095. or two or more of these bits combined using C<|>.
  1096.  
  1097. C<$pSecDesc> contains the new C<SECURITY_DESCRIPTOR> structure
  1098. packed into a Perl string.
  1099.  
  1100. =item RegSetValue
  1101.  
  1102. =item C<RegSetValue( $hKey, $sSubKey, $uType, $sValueData, $lValueData )>
  1103.  
  1104. This routine is meant only for compatibility with Windows version
  1105. 3.1.  Use C<RegSetValueEx()> instead.  This routine can only
  1106. set unamed values [a.k.a. "default values"].
  1107.  
  1108. =item RegSetValueEx
  1109.  
  1110. =item C<RegSetValueEx( $hKey, $sName, $uZero, $uType, $pData, $lData )>
  1111.  
  1112. Adds or replaces a value in an open Registry key.  Returns
  1113. a true value if successful and a false value [and sets
  1114. C<$^E>/C<regLastError()>] on failure.
  1115.  
  1116. C<$hKey> is the handle to a Registry key [either C<HKEY_*> or from
  1117. a previous call].
  1118.  
  1119. C<$sName> is the name of the value to be set.
  1120.  
  1121. C<$uZero> is reserved for future use and should be specified as C<0>.
  1122.  
  1123. C<$uType> is the type of data stored in C<$pData>.  It should
  1124. be a C<REG_*> value.
  1125.  
  1126. C<$pData> is the value data packed into a Perl string.
  1127.  
  1128. C<$lData> is the length of the value data that is stored in C<$pData>.
  1129. You will usually omit this parameter or pass in C<0> to have
  1130. C<length($pData)> used.  In both of these cases, if C<$iType> is
  1131. C<REG_SZ> or C<REG_EXPAND_SZ>, C<RegSetValueEx()> will append a
  1132. trailing C<'\0'> to the end of C<$pData> [unless there is already
  1133. one].
  1134.  
  1135. =item RegUnLoadKey
  1136.  
  1137. =item C<RegUnLoadKey( $hKey, $sSubKey )>
  1138.  
  1139. Unloads a previously loaded hive file.  That is, closes the
  1140. hive file then deletes the subkey that was providing access
  1141. to it.  Returns a true value if successful and a false value
  1142. [and sets C<$^E>/C<regLastError()>] on failure.
  1143.  
  1144. C<$hKey> is the handle to a Registry key that has hives
  1145. loaded in it.  This must be C<HKEY_LOCAL_MACHINE>, C<HKEY_USERS>,
  1146. or a remote version of one of these from a call to
  1147. C<RegConnectRegistry()>.
  1148.  
  1149. C<$sSubKey> is the name of the subkey whose hive you wish to
  1150. have unloaded.
  1151.  
  1152. =item :FuncA
  1153.  
  1154. The ASCII-specific function names.
  1155.  
  1156. Each of these is identical to the version listed above without the
  1157. trailing "A":
  1158.  
  1159.     AbortSystemShutdownA    InitiateSystemShutdownA
  1160.     RegConnectRegistryA    RegCreateKeyA        RegCreateKeyExA
  1161.     RegDeleteKeyA        RegDeleteValueA        RegEnumKeyA
  1162.     RegEnumKeyExA        RegEnumValueA        RegLoadKeyA
  1163.     RegOpenKeyA        RegOpenKeyExA        RegQueryInfoKeyA
  1164.     RegQueryMultipleValuesA    RegQueryValueA        RegQueryValueExA
  1165.     RegReplaceKeyA        RegRestoreKeyA        RegSaveKeyA
  1166.     RegSetValueA        RegSetValueExA        RegUnLoadKeyA
  1167.  
  1168. =item :FuncW
  1169.  
  1170. The UNICODE-specific function names.  These are the same as the
  1171. versions listed above without the trailing "W" except that string
  1172. parameters are UNICODE strings rather than ASCII strings, as
  1173. indicated.
  1174.  
  1175. =item AbortSystemShutdownW
  1176.  
  1177. =item C<AbortSystemShutdownW( $swComputerName )>
  1178.  
  1179. C<$swComputerName> is UNICODE.
  1180.  
  1181. =item InitiateSystemShutdownW
  1182.  
  1183. =item C<InitiateSystemShutdownW( $swComputer, $swMessage, $uTimeoutSecs, $bForce, $bReboot )>
  1184.  
  1185. C<$swComputer> and C<$swMessage> are UNICODE.
  1186.  
  1187. =item RegConnectRegistryW
  1188.  
  1189. =item C<RegConnectRegistryW( $swComputer, $hRootKey, $ohKey )>
  1190.  
  1191. C<$swComputer> is UNICODE.
  1192.  
  1193. =item RegCreateKeyW
  1194.  
  1195. =item C<RegCreateKeyW( $hKey, $swSubKey, $ohSubKey )>
  1196.  
  1197. C<$swSubKey> is UNICODE.
  1198.  
  1199. =item RegCreateKeyExW
  1200.  
  1201. =item C<RegCreateKeyExW( $hKey, $swSubKey, $uZero, $swClass, $uOpts, $uAccess, $pSecAttr, $ohNewKey, $ouDisp )>
  1202.  
  1203. C<$swSubKey> and C<$swClass> are UNICODE.
  1204.  
  1205. =item RegDeleteKeyW
  1206.  
  1207. =item C<RegDeleteKeyW( $hKey, $swSubKey )>
  1208.  
  1209. C<$swSubKey> is UNICODE.
  1210.  
  1211. =item RegDeleteValueW
  1212.  
  1213. =item C<RegDeleteValueW( $hKey, $swValueName )>
  1214.  
  1215. C<$swValueName> is UNICODE.
  1216.  
  1217. =item RegEnumKeyW
  1218.  
  1219. =item C<RegEnumKeyW( $hKey, $uIndex, $oswName, $ilwNameSize )>
  1220.  
  1221. C<$oswName> is UNICODE and C<$ilwNameSize> is measured as number of
  1222. C<WCHAR>s.
  1223.  
  1224. =item RegEnumKeyExW
  1225.  
  1226. =item C<RegEnumKeyExW( $hKey, $uIndex, $oswName, $iolwName, $pNull, $oswClass, $iolwClass, $opftLastWrite )>
  1227.  
  1228. C<$swName> and C<$swClass> are UNICODE and C<$iolwName> and C<$iolwClass>
  1229. are measured as number of C<WCHAR>s.
  1230.  
  1231. =item RegEnumValueW
  1232.  
  1233. =item C<RegEnumValueW( $hKey, $uIndex, $oswName, $iolwName, $pNull, $ouType, $opData, $iolData )>
  1234.  
  1235. C<$oswName> is UNICODE and C<$iolwName> is measured as number
  1236. of C<WCHAR>s.
  1237.  
  1238. C<$opData> is UNICODE if C<$piType> is C<REG_SZ>, C<REG_EXPAND_SZ>,
  1239. or C<REG_MULTI_SZ>.  Note that C<$iolData> is measured as number
  1240. of bytes even in these cases.
  1241.  
  1242. =item RegLoadKeyW
  1243.  
  1244. =item C<RegLoadKeyW( $hKey, $swSubKey, $swFileName )>
  1245.  
  1246. C<$swSubKey> and C<$swFileName> are UNICODE.
  1247.  
  1248. =item RegOpenKeyW
  1249.  
  1250. =item C<RegOpenKeyW( $hKey, $swSubKey, $ohSubKey )>
  1251.  
  1252. C<$swSubKey> is UNICODE.
  1253.  
  1254. =item RegOpenKeyExW
  1255.  
  1256. =item C<RegOpenKeyExW( $hKey, $swSubKey, $uOptions, $uAccess, $ohSubKey )>
  1257.  
  1258. C<$swSubKey> is UNICODE.
  1259.  
  1260. =item RegQueryInfoKeyW
  1261.  
  1262. =item C<RegQueryInfoKeyW( $hKey, $oswClass, $iolwClass, $pNull, $ocSubKeys, $olwSubKey, $olwSubClass, $ocValues, $olwValName, $olValData, $olSecDesc, $opftTime )>
  1263.  
  1264. C<$swClass> is UNICODE.  C<$iolwClass>, C<$olwSubKey>, C<$olwSubClass>,
  1265. and C<$olwValName> are measured as number of C<WCHAR>s.  Note that
  1266. C<$olValData> is measured as number of bytes.
  1267.  
  1268. =item RegQueryMultipleValuesW
  1269.  
  1270. =item C<RegQueryMultipleValuesW( $hKey, $ioarValueEnts, $icValueEnts, $opBuffer, $iolBuffer )>
  1271.  
  1272. The C<ve_valuename> fields of the C<VALENT> [actually C<VALENTW>]
  1273. structures in C<$ioarValueEnts> are UNICODE.  Values of type C<REG_SZ>,
  1274. C<REG_EXPAND_SZ>, and C<REG_MULTI_SZ> are written to C<$opBuffer>
  1275. in UNICODE.  Note that C<$iolBuffer> and the C<ve_valuelen> fields
  1276. of the C<VALENT> [C<VALENTW>] structures are measured as number of
  1277. bytes.
  1278.  
  1279. =item RegQueryValueW
  1280.  
  1281. =item C<RegQueryValueW( $hKey, $swSubKey, $oswValueData, $iolValueData )>
  1282.  
  1283. C<$swSubKey> and C<$oswValueData> are UNICODE.  Note that
  1284. C<$iolValueData> is measured as number of bytes.
  1285.  
  1286. =item RegQueryValueExW
  1287.  
  1288. =item C<RegQueryValueExW( $hKey, $swName, $pNull, $ouType, $opData, $iolData )>
  1289.  
  1290. C<$swName> is UNICODE.
  1291.  
  1292. C<$opData> is UNICODE if C<$ouType> is C<REG_SZ>, C<REG_EXPAND_SZ>,
  1293. or C<REG_MULTI_SZ>.  Note that C<$iolData> is measured as number of
  1294. bytes even in these cases.
  1295.  
  1296. =item RegReplaceKeyW
  1297.  
  1298. =item C<RegReplaceKeyW( $hKey, $swSubKey, $swNewFile, $swOldFile )>
  1299.  
  1300. C<$swSubKey>, C<$swNewFile>, and C<$swOldFile> are UNICODE.
  1301.  
  1302. =item RegRestoreKeyW
  1303.  
  1304. =item C<RegRestoreKeyW( $hKey, $swFileName, $uFlags )>
  1305.  
  1306. C<$swFileName> is UNICODE.
  1307.  
  1308. =item RegSaveKeyW
  1309.  
  1310. =item C<RegSaveKeyW( $hKey, $swFileName, $pSecAttr )>
  1311.  
  1312. C<$swFileName> is UNICODE.
  1313.  
  1314. =item RegSetValueW
  1315.  
  1316. =item C<RegSetValueW( $hKey, $swSubKey, $uType, $swValueData, $lValueData )>
  1317.  
  1318. C<$swSubKey> and C<$swValueData> are UNICODE.  Note that
  1319. C<$lValueData> is measured as number of bytes even though
  1320. C<$swValueData> is always UNICODE.
  1321.  
  1322. =item RegSetValueExW
  1323.  
  1324. =item C<RegSetValueExW( $hKey, $swName, $uZero, $uType, $pData, $lData )>
  1325.  
  1326. C<$swName> is UNICODE.
  1327.  
  1328. C<$pData> is UNICODE if C<$uType> is C<REG_SZ>, C<REG_EXPAND_SZ>,
  1329. or C<REG_MULTI_SZ>.  Note that C<$lData> is measured as number of
  1330. bytes even in these cases.
  1331.  
  1332. =item RegUnLoadKeyW
  1333.  
  1334. =item C<RegUnLoadKeyW( $hKey, $swSubKey )>
  1335.  
  1336. C<$swSubKey> is UNICODE.
  1337.  
  1338. =item :HKEY_
  1339.  
  1340. All C<HKEY_*> constants:
  1341.  
  1342.     HKEY_CLASSES_ROOT    HKEY_CURRENT_CONFIG    HKEY_CURRENT_USER
  1343.     HKEY_DYN_DATA        HKEY_LOCAL_MACHINE    HKEY_PERFORMANCE_DATA
  1344.     HKEY_USERS
  1345.  
  1346. =item :KEY_
  1347.  
  1348. All C<KEY_*> constants:
  1349.  
  1350.     KEY_QUERY_VALUE        KEY_SET_VALUE        KEY_CREATE_SUB_KEY
  1351.     KEY_ENUMERATE_SUB_KEYS    KEY_NOTIFY        KEY_CREATE_LINK
  1352.     KEY_READ        KEY_WRITE        KEY_EXECUTE
  1353.     KEY_ALL_ACCESS
  1354.  
  1355. =item :REG_
  1356.  
  1357. All C<REG_*> constants:
  1358.  
  1359.     REG_CREATED_NEW_KEY        REG_OPENED_EXISTING_KEY
  1360.  
  1361.     REG_LEGAL_CHANGE_FILTER        REG_NOTIFY_CHANGE_ATTRIBUTES
  1362.     REG_NOTIFY_CHANGE_NAME        REG_NOTIFY_CHANGE_LAST_SET
  1363.     REG_NOTIFY_CHANGE_SECURITY    REG_LEGAL_OPTION
  1364.  
  1365.     REG_OPTION_BACKUP_RESTORE    REG_OPTION_CREATE_LINK
  1366.     REG_OPTION_NON_VOLATILE        REG_OPTION_OPEN_LINK
  1367.     REG_OPTION_RESERVED        REG_OPTION_VOLATILE
  1368.  
  1369.     REG_WHOLE_HIVE_VOLATILE        REG_REFRESH_HIVE
  1370.     REG_NO_LAZY_FLUSH
  1371.  
  1372.     REG_NONE            REG_SZ
  1373.     REG_EXPAND_SZ            REG_BINARY
  1374.     REG_DWORD            REG_DWORD_LITTLE_ENDIAN
  1375.     REG_DWORD_BIG_ENDIAN        REG_LINK
  1376.     REG_MULTI_SZ            REG_RESOURCE_LIST
  1377.     REG_FULL_RESOURCE_DESCRIPTOR    REG_RESOURCE_REQUIREMENTS_LIST
  1378.  
  1379. =item :ALL
  1380.  
  1381. All of the above.
  1382.  
  1383. =item :SE_
  1384.  
  1385. The strings for the following privilege names:
  1386.  
  1387.     SE_ASSIGNPRIMARYTOKEN_NAME    SE_AUDIT_NAME
  1388.     SE_BACKUP_NAME            SE_CHANGE_NOTIFY_NAME
  1389.     SE_CREATE_PAGEFILE_NAME        SE_CREATE_PERMANENT_NAME
  1390.     SE_CREATE_TOKEN_NAME        SE_DEBUG_NAME
  1391.     SE_INCREASE_QUOTA_NAME        SE_INC_BASE_PRIORITY_NAME
  1392.     SE_LOAD_DRIVER_NAME        SE_LOCK_MEMORY_NAME
  1393.     SE_MACHINE_ACCOUNT_NAME        SE_PROF_SINGLE_PROCESS_NAME
  1394.     SE_REMOTE_SHUTDOWN_NAME        SE_RESTORE_NAME
  1395.     SE_SECURITY_NAME        SE_SHUTDOWN_NAME
  1396.     SE_SYSTEMTIME_NAME        SE_SYSTEM_ENVIRONMENT_NAME
  1397.     SE_SYSTEM_PROFILE_NAME        SE_TAKE_OWNERSHIP_NAME
  1398.     SE_TCB_NAME            SE_UNSOLICITED_INPUT_NAME
  1399.  
  1400. It can be difficult to successfully build this module in a way
  1401. that makes these constants available.  So some builds of this
  1402. module may not make them available.  For such builds, trying
  1403. to export any of these constants will cause a fatal error.
  1404. For this reason, none of these symbols are currently included
  1405. in the C<":ALL"> grouping.
  1406.  
  1407. =back
  1408.  
  1409. =head2 The Win32API:: heirarchy
  1410.  
  1411. This and the other Win32API:: modules are meant to expose the
  1412. nearly raw API calls so they can be used from Perl code in any
  1413. way they might be used from C code.  This provides the following
  1414. advantages:
  1415.  
  1416. =over
  1417.  
  1418. =item Many modules can be written by people that don't have a C compiler.
  1419.  
  1420. =item Encourages more module code to be written in Perl [not C].
  1421.  
  1422. Perl code is often much easier to inspect, debug, customize, and
  1423. enhance than XS code.
  1424.  
  1425. =item Allows those already familiar with the Win32 API to get
  1426. off to a quick start.
  1427.  
  1428. =item Provides an interactive tool for exploring even obscure
  1429. details of the Win32 API.
  1430.  
  1431. It can be very useful to interactively explore ad-hoc calls into
  1432. parts of the Win32 API using:
  1433.  
  1434.     perl -de 0
  1435.  
  1436. =item Ensures that native Win32 data structures can be used.
  1437.  
  1438. This allows maximum efficiency.  It also allows data from one
  1439. module [for example, time or security information from the
  1440. C<Win32API::Registry> or C<Win32API::File> modules] to be used
  1441. with other modules [for example, C<Win32API::Time> and
  1442. C<Win32API::SecDesc>].
  1443.  
  1444. =item Provides a single version of the XS interface to each API
  1445. call where improvements can be collected.
  1446.  
  1447. =back
  1448.  
  1449. =head2 Buffer sizes
  1450.  
  1451. For each parameter that specifies a buffer size, a value of C<0>
  1452. can be passed.  For parameter that are pointers to buffer sizes,
  1453. you can also pass in C<NULL> by specifying an empty list reference,
  1454. C<[]>.  Both of these cases will ensure that the variable has
  1455. E<some> buffer space allocated to it and pass in that buffer's
  1456. allocated size.  Many of the calls indicate, via C<ERROR_MORE_DATA>,
  1457. that the buffer size was not sufficient and the F<Registry.xs>
  1458. code will automatically enlarge the buffer to the required size
  1459. and repeat the call.
  1460.  
  1461. Numeric buffer sizes are used as minimum initial sizes for the
  1462. buffers.  The larger of this size and the size of space already
  1463. allocated to the scalar will be passed to the underlying routine. 
  1464. If that size was insufficient, and the underlying call provides
  1465. an easy method for determining the needed buffer size, then the
  1466. buffer will be enlarged and the call repeated as above.
  1467.  
  1468. The underlying calls define buffer size parameter as unsigned, so
  1469. negative buffer sizes are treated as very large positive buffer
  1470. sizes which usually cause C<malloc()> to fail.
  1471.  
  1472. To force the F<Registry.xs> code to pass in a specific value for
  1473. a buffer size, preceed the size with an equals sign via C<"=".>. 
  1474. Buffer sizes that are passed in as strings starting with an equals
  1475. sign will have the equal sign stripped and the remainder of the string
  1476. interpretted as a number [via C's C<strtoul()> using only base 10]
  1477. which will be passed to the underlying routine [even if the allocated
  1478. buffer is actually larger].  The F<Registry.xs> code will enlarge the
  1479. buffer to the specified size, if needed, but will not enlarge the
  1480. buffer based on the underlying routine requesting more space.
  1481.  
  1482. Some Reg*() calls may not currently set the buffer size when they
  1483. return C<ERROR_MORE_DATA>.  But some that are not documented as
  1484. doing so, currently do so anyway.  So the code assumes that any
  1485. routine E<might> do this and resizes any buffers and repeats the
  1486. call.   We hope that eventually all routines will provide this
  1487. feature.
  1488.  
  1489. When you use C<[]> for a buffer size, you can still find the
  1490. length of the data returned by using C<length($buffer)>.  Note
  1491. that this length will be in bytes while a few of the buffer
  1492. sizes would have been in units of wide characters.
  1493.  
  1494. Note that the RegQueryValueEx*() and RegEnumValue*() calls
  1495. will trim the trailing C<'\0'> [if present] from the returned data
  1496. values of type C<REG_SZ> or C<REG_EXPAND_SZ> but only if the
  1497. value data length parameter is omitted [or specified as C<[]>].
  1498.  
  1499. The RegSetValueEx*() calls will add a trailing C<'\0'> [if
  1500. missing] to the supplied data values of type C<REG_SZ> and
  1501. C<REG_EXPAND_SZ> but only if the value data length parameter
  1502. is omitted [or specified as C<0>].
  1503.  
  1504. =head2 Hungarian Notation
  1505.  
  1506. The following abbreviations are used at the start of each parameter
  1507. name to hint at aspects of how the parameter is used.  The prefix
  1508. is always in lower case and followed by a capital letter that starts
  1509. the descriptive part of the parameter name.  Several of the following
  1510. abbreviations can be combined into a single prefix.
  1511.  
  1512. Probably not all of these prefix notations are used by this module. 
  1513. This document section may be included in any C<Win32API> module and
  1514. so covers some notations not used by this specific module.
  1515.  
  1516. =over
  1517.  
  1518. =item s
  1519.  
  1520. A string.  In C, a C<'\0'>-terminated C<char *>.  In Perl, just a
  1521. string except that it will be truncated at the first C<"\0">, if
  1522. it contains one.
  1523.  
  1524. =item sw
  1525.  
  1526. A wide [UNICODE] string.  In C, a C<L'\0'>-terminated C<WCHAR *>.
  1527. In Perl, a string that contains UNICODE data.  You can convert a
  1528. string to UNICODE in Perl via:
  1529.  
  1530.     $string= "This is an example string";
  1531.     $unicode= pack( "S*", unpack("C*",$string), 0 );
  1532.  
  1533. Note how C<, 0> above causes an explicit C<L'\0'> to be added since
  1534. Perl's implicit C<'\0'> that it puts after each of its strings is not
  1535. wide enough to terminate a UNICODE string.  So UNICODE strings are
  1536. different than regular strings in that the Perl version of a regular
  1537. string will not include the trialing C<'\0'> while the Perl version
  1538. of a UNICODE string must include the trailing C<L'\0'>.
  1539.  
  1540. If a UNICODE string contains no non-ASCII characters, then you
  1541. can convert it back into a normal string via:
  1542.  
  1543.     $string= pack( "C*", unpack("S*",$unicode) );
  1544.     $string =~ s/\0$//;
  1545.  
  1546. =item p
  1547.  
  1548. A pointer to some buffer [usually containing some C<struct>].  In C,
  1549. a C<void *> or some other pointer type.  In Perl, a string that is
  1550. usually manipulated using C<pack> and C<unpack>.  The "p" is usually
  1551. followed by more prefix character(s) to indicate what type of data is
  1552. stored in the bufffer.
  1553.  
  1554. =item a
  1555.  
  1556. A packed array.  In C, an array [usually of C<struct>s].  In Perl, a
  1557. string containing the packed data.  The "a" is usually followed by
  1558. more prefix character(s) to indicate the data type of the elements.
  1559.  
  1560. These packed arrays are also called "vectors" in places to avoid
  1561. confusion with Perl arrays.
  1562.  
  1563. =item n
  1564.  
  1565. A generic number.   In C, any of the integer or floating point data
  1566. types.  In Perl, a number; either an integer, unsigned, or double
  1567. [IV, UV, or NV, respectively].  Usually an integer.
  1568.  
  1569. =item iv
  1570.  
  1571. A signed integral value.  In C, any of the signed integer data types. 
  1572. In Perl, an integer [IV].
  1573.  
  1574. =item u
  1575.  
  1576. An unsigned integral value.  In C, any of the unsigned integer data
  1577. types.  In Perl, an unsigned integer [UV].
  1578.  
  1579. =item d
  1580.  
  1581. A floating-point number.  In C, a C<float> or C<double> or, perhaps,
  1582. a C<long double>.  In Perl, a double-precision floating-point number
  1583. [NV].
  1584.  
  1585. =item b
  1586.  
  1587. A Boolean value.  In C, any integer data type, though usually via
  1588. a type alias of C<bool> or C<BOOL>, containing either a 0 [false] or
  1589. non-zero [true] value.  In Perl, a scalar containing a Boolean value
  1590. [C<0>, C<"">, or C<undef> for "false" and anything else for "true"].
  1591.  
  1592. =item c
  1593.  
  1594. A count of items.  In C, any integer data type.  In Perl, an unsigned
  1595. integer [UV].  Usually used in conjunction with a "vector" parameter
  1596. [see L</a> above] to indicate the number of elements.
  1597.  
  1598. =item l
  1599.  
  1600. A length [in bytes].  In C, any integer data type.  In Perl, an
  1601. unsigned integer [UV].  Usually used in conjunction with a "string"
  1602. or "pointer" parameter [see L</s> and L</p> above] to indicate the
  1603. buffer size or the size of the value stored in the buffer.
  1604.  
  1605. For strings, there is no general rule as to whether the trailing
  1606. C<'\0'> is included in such sizes.  For this reason, the C<Win32API>
  1607. modules follow the Perl rule of always allocating one extra byte
  1608. and reporting buffer sizes as being one smaller than allocated in
  1609. case the C<'\0'> is not included in the size.
  1610.  
  1611. =item lw
  1612.  
  1613. A length measured as number of UNICODE characters.  In C, a count
  1614. of C<WCHAR>s.  In Perl, an unsigned integer [UV] counting "shorts"
  1615. [see "s" and "S" in C<pack> and C<unpack>].
  1616.  
  1617. For UNICODE strings, the trailing C<L'\0'> may or may not be
  1618. included in a length so, again, we always allocate extra room
  1619. for one and don't report that extra space.
  1620.  
  1621. =item h
  1622.  
  1623. A handle.  In C, a C<HANDLE> or more-specific handle data type. 
  1624. In Perl, an unsigned integer [UV].  In C, these handles are often
  1625. actually some type of pointer, but Perl just treats them as opaque
  1626. numbers, as it should.  This prefix is also used for other pointers
  1627. that are treated as integers in Perl code.
  1628.  
  1629. =item r
  1630.  
  1631. A record.  In C, almost always a C<struct> or perhaps C<union>.  Note
  1632. that C C<struct>s are rarely passed by value so the "r" is almost
  1633. always preceeded by a "p" or "a" [see L</p> and L</a> above].  For
  1634. the very rare unadorned "r", Perl stores the record in the same way
  1635. as a "pr", that is, in a string.  For the very rare case where Perl
  1636. explicitly stores a pointer to the C<struct> rather than storing the
  1637. C<struct> directly in a Perl string, the prefix "pp" or "ppr" or even
  1638. "par" is used.
  1639.  
  1640. =item sv
  1641.  
  1642. =item rv
  1643.  
  1644. =item hv
  1645.  
  1646. =item av
  1647.  
  1648. =item cv
  1649.  
  1650. A Perl data type.  Respectively, a scalar value [SV], a reference
  1651. [RV] [usually to a scalar], a hash [HV], a Perl array [AV], or a Perl
  1652. code reference [PVCV].  For the "hv", "av", and "cv" prefixes, a
  1653. leading "rv" is usually assumed.  For a parameter to an XS subroutine,
  1654. a prefix of "sv" means the parameter is a scalar and so may be a string
  1655. or a number [or C<undef>] or even both at the same time.  So "sv"
  1656. doesn't imply a leading "rv".
  1657.  
  1658. =item Input or Output
  1659.  
  1660. Whether a parameter is for input data, output data, or both is usually
  1661. not reflected by the data type prefix.  In cases where this is not
  1662. obvious nor reflected in the parameter name proper, we may use the
  1663. following in front of the data type prefix.
  1664.  
  1665. =over
  1666.  
  1667. =item i
  1668.  
  1669. An input parameter given to the API [usually omitted].
  1670.  
  1671. =item o
  1672.  
  1673. An output-only parameter taken from the API.  You should not get a
  1674. warning if such a parameter is C<undef> when you pass it into the
  1675. function.  You should get an error if such a parameter is read-only.
  1676. You can [usually] pass in C<[]> for such a parameter to have the
  1677. parameter silently ignored.
  1678.  
  1679. The output may be written directly into the Perl variable passed
  1680. to the subroutine, the same way the buffer parameter to Perl's
  1681. C<sysread()>.  This method is often avoided in Perl because
  1682. the call then lacks any visual cue that some parameters are being
  1683. overwritten.   But this method closely matches the C API which is
  1684. what we are trying to do.
  1685.  
  1686. =item io
  1687.  
  1688. Input given to the API then overwritten with output taken from the
  1689. API.  You should get a warning [if B<-w> is in effect] if such a
  1690. parameter is C<undef> when you pass it into the function [unless it
  1691. is a buffer or buffer length parameter].  If the value is read-only,
  1692. then [for most parameters] the output is silently not written.  This
  1693. is because it is often convenient to pass in read-only constants for
  1694. many such parameters.  You can also usually pass in C<[]> for such
  1695. parameters.
  1696.  
  1697. =back
  1698.  
  1699. =item pp
  1700.  
  1701. =item ppr
  1702.  
  1703. =item par
  1704.  
  1705. =item pap
  1706.  
  1707. These are just unusual combinations of prefix characters described above.
  1708.  
  1709. For each, a pointer is stored in a [4-byte] Perl string.  You can
  1710. usually use C<unpack "P"> to access the real data from Perl.
  1711.  
  1712. For "ppr" [and often for "pp"], the pointer points directly at a
  1713. C C<struct>.  For "par", the pointer points to the first element
  1714. of a C [packed] array of C<struct>s.  For "pap", the pointer points
  1715. to a C [packed] array of pointers to other things.
  1716.  
  1717. =item ap
  1718.  
  1719. Here we have a list of pointers packed into a single Perl string.
  1720.  
  1721. =back
  1722.  
  1723. =head1 BUGS
  1724.  
  1725. The old ActiveState ports of Perl for Win32 [but not, ActivePerl, the
  1726. ActiveState distributions of standard Perl 5.004 and beyond] do not support
  1727. the tools for building extensions and so do not support this extension.
  1728.  
  1729. No routines are provided for using the data returned in the C<FILETIME>
  1730. buffers.  Those are in the C<Win32API::Time> module.
  1731.  
  1732. No routines are provided for dealing with UNICODE data effectively. 
  1733. See L</:FuncW> above for some simple-minded UNICODE methods.
  1734.  
  1735. Parts of the module test will fail if used on a version of Perl
  1736. that does not yet set C<$^E> based on C<GetLastError()>.
  1737.  
  1738. On NT 4.0 [at least], the RegEnum*() calls do not set the required
  1739. buffer sizes when returning C<ERROR_MORE_DATA> so this module will
  1740. not grow the buffers in such cases.  C<Win32::TieRegistry> overcomes
  1741. this by using values from C<RegQueryInfoKey()> for buffer sizes in
  1742. RegEnum* calls.
  1743.  
  1744. On NT 4.0 [at least], C<RegQueryInfoKey()> on C<HKEY_PERFORMANCE_DATA>
  1745. never succeeds.  Also, C<RegQueryValueEx()> on C<HKEY_PERFORMANCE_DATA>
  1746. never returns the required buffer size.  To access C<HKEY_PERFORMANCE_DATA>
  1747. you will need to keep growing the data buffer until the call succeeds.
  1748.  
  1749. Because C<goto &subroutine> seems to be buggy under Win32 Perl,
  1750. it is not used in the stubs in F<Registry.pm>.
  1751.  
  1752. =head1 AUTHOR
  1753.  
  1754. Tye McQueen, tye@metronet.com, http://www.metronet.com/~tye/.
  1755.  
  1756. =head1 SEE ALSO
  1757.  
  1758. =over
  1759.  
  1760. =item L<Win32::TieRegistry>
  1761.  
  1762. =item L<Win32::Registry>
  1763.  
  1764. =back
  1765.  
  1766. =cut
  1767.