⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registry.html

📁 perl教程
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Win32API::Registry - Low-level access to Win32 system API calls from WINREG.H</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>Win32API::Registry - Low-level access to Win32 system API calls from WINREG.H</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#exports">Exports</a></li>
		<li><a href="#the_win32api___heirarchy">The Win32API:: heirarchy</a></li>
		<li><a href="#buffer_sizes">Buffer sizes</a></li>
		<li><a href="#hungarian_notation">Hungarian Notation</a></li>
	</ul>

	<li><a href="#bugs">BUGS</a></li>
	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32API::Registry - Low-level access to Win32 system API calls from WINREG.H</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
  <span class="keyword">use</span> <span class="variable">Win32API::Registry</span> <span class="number">0</span><span class="operator">.</span><span class="number">21</span> <span class="string">qw( :ALL )</span><span class="operator">;</span>
</pre>
<pre>
  <span class="variable">RegOpenKeyEx</span><span class="operator">(</span> <span class="variable">HKEY_LOCAL_MACHINE</span><span class="operator">,</span> <span class="string">"SYSTEM\\Disk"</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="variable">KEY_READ</span><span class="operator">,</span> <span class="variable">$key</span> <span class="operator">);</span>
    <span class="keyword">or</span>  <span class="keyword">die</span> <span class="string">"Can't open HKEY_LOCAL_MACHINE\\SYSTEM\\Disk: "</span><span class="operator">,</span>
            <span class="variable">regLastError</span><span class="operator">(),</span><span class="string">"\n"</span><span class="operator">;</span>
  <span class="variable">RegQueryValueEx</span><span class="operator">(</span> <span class="variable">$key</span><span class="operator">,</span> <span class="string">"Information"</span><span class="operator">,</span> <span class="operator">[]</span><span class="operator">,</span> <span class="variable">$type</span><span class="operator">,</span> <span class="variable">$data</span><span class="operator">,</span> <span class="operator">[]</span> <span class="operator">);</span>
    <span class="keyword">or</span>  <span class="keyword">die</span> <span class="string">"Can't read HKEY_L*MACHINE\\SYSTEM\\Disk\\Information: "</span><span class="operator">,</span>
            <span class="variable">regLastError</span><span class="operator">(),</span><span class="string">"\n"</span><span class="operator">;</span>
  <span class="operator">[</span><span class="operator">...</span><span class="operator">]</span>
  <span class="variable">RegCloseKey</span><span class="operator">(</span> <span class="variable">$key</span> <span class="operator">)</span>
    <span class="keyword">or</span>  <span class="keyword">die</span> <span class="string">"Can't close HKEY_LOCAL_MACHINE\\SYSTEM\\Disk: "</span><span class="operator">,</span>
            <span class="variable">regLastError</span><span class="operator">(),</span><span class="string">"\n"</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This provides fairly low-level access to the Win32 System API
calls dealing with the Registry [mostly from WINREG.H].  This
is mostly intended to be used by other modules such as
<a href="#item_win32_3a_3atieregistry"><code>Win32::TieRegistry</code></a> [which provides an extremely Perl-friendly
method for using the Registry].</p>
<p>For a description of the logical structure of the Registry, see
the documentation for the <a href="#item_win32_3a_3atieregistry"><code>Win32::TieRegistry</code></a> module.</p>
<p>To pass in <code>NULL</code> as the pointer to an optional buffer, pass in
an empty list reference, <code>[]</code>.</p>
<p>Beyond raw access to the API calls and related constants, this module
handles smart buffer allocation and translation of return codes.</p>
<p>All calls return a true value for success and a false value for
failure.  After any failure, <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> should automatically be set
to indicate the reason.  However, current versions of Perl often
overwrite <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> too quickly, so you can use <a href="#item_reglasterror"><code>regLastError()</code></a>
instead, which is only set by Win32API::Registry routines.</p>
<p>Note that <a href="../../lib/Pod/perlvar.html#item___"><code>$!</code></a> is not set by these routines except by
<code>Win32API::Registry::constant()</code> when a constant is not defined.</p>
<p>
</p>
<h2><a name="exports">Exports</a></h2>
<p>Nothing is exported by default.  The following tags can be used to
have sets of symbols exported.</p>
<p>[Note that much of the following documentation refers to the
behavior of the underlying API calls which may vary in current
and future versions of the Win32 API without any changes to this
module.  Therefore you should check the Win32 API documentation
directly when needed.]</p>
<dl>
<dt><strong><a name="item__3afunc">:Func</a></strong>

<dd>
<p>The basic function names:</p>
</dd>
<dl>
<dt><strong><a name="item_allowpriv">AllowPriv</a></strong>

<dt><strong><code>AllowPriv( $sPrivName, $bEnable )</code></strong>

<dd>
<p>Not a Win32 API call.  Enables or disables a specific privilege for
the current process.  Returns a true value if successful and a false
value [and sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.  This routine
does not provide a way to tell if a privilege is currently enabled.</p>
</dd>
<dd>
<p><code>$sPrivname</code> is a Win32 privilege name [see <a href="#item__3ase_">:SE_</a>].  For example,
<code>&quot;SeBackupPrivilege&quot;</code> [a.k.a. <code>SE_BACKUP_NAME</code>] controls whether
you can use <a href="#item_regsavekey"><code>RegSaveKey()</code></a> and <code>&quot;SeRestorePrivilege&quot;</code> [a.k.a.
<code>SE_RESTORE_NAME</code>] controls whether you can use <a href="#item_regloadkey"><code>RegLoadKey()</code></a>.</p>
</dd>
<dd>
<p>If <code>$bEnable</code> is true, then <a href="#item_allowpriv"><code>AllowPriv()</code></a> tries to enable the
privilege.  Otherwise it tries to disable the privilege.</p>
</dd>
</li>
<dt><strong><a name="item_abortsystemshutdown">AbortSystemShutdown</a></strong>

<dt><strong><code>AbortSystemShutdown( $sComputerName )</code></strong>

<dd>
<p>Tries to abort a remote shutdown request previously made via
<a href="#item_initiatesystemshutdown"><code>InitiateSystemShutdown()</code></a>.  Returns a true value if successful
and a false value [and sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.</p>
</dd>
</li>
<dt><strong><a name="item_initiatesystemshutdown">InitiateSystemShutdown</a></strong>

<dt><strong><code>InitiateSystemShutdown( $sComputer, $sMessage, $uTimeoutSecs, $bForce, $bReboot )</code></strong>

<dd>
<p>Requests that a [remote] computer be shutdown or rebooted.
Returns a true value if successful and a false value [and
sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.</p>
</dd>
<dd>
<p><code>$sComputer</code> is the name [or address] of the computer to be
shutdown or rebooted.  You can use <code>[]</code> [for <code>NULL</code>] or <code>&quot;&quot;</code>
to indicate the local computer.</p>
</dd>
<dd>
<p><code>$sMessage</code> is the message to be displayed in a pop-up window
on the desktop of the computer to be shutdown or rebooted until
the timeout expires or the shutdown is aborted via
<a href="#item_abortsystemshutdown"><code>AbortSystemShutdown()</code></a>.  With <code>$iTimeoutSecs == 0</code>, the
message will never be visible.</p>
</dd>
<dd>
<p><code>$iTimeoutSecs</code> is the number of seconds to wait before starting
the shutdown.</p>
</dd>
<dd>
<p>If <code>$bForce</code> is false, then any applications running on the remote
computer get a chance to prompt the remote user whether they want
to save changes.  Also, for any applications that do not exit quickly
enough, the operating system will prompt the user whether they wish
to wait longer for the application to exit or force it to exit now.
At any of these prompts the user can press <strong>CANCEL</strong> to abort the
shutdown but if no applications have unsaved data, they will likely
all exit quickly and the shutdown will progress with the remote user
having no option to cancel the shutdown.</p>
</dd>
<dd>
<p>If <code>$bForce</code> is true, all applications are told to exit immediately
and so will not prompt the user even if there is unsaved data.  Any
applications that take too long to exit will be forcibly killed after
a short time.  The only way to abort the shutdown is to call
<a href="#item_abortsystemshutdown"><code>AbortSystemShutdown()</code></a> before the timeout expires and there is no
way to abort the shutdown once it has begun.</p>
</dd>
<dd>
<p>If <code>$bReboot</code> is true, the computer will automatically reboot once
the shutdown is complete.  If <code>$bReboot</code> is false, then when the
shutdown is complete the computer will halt at a screen indicating
that the shutdown is complete and offering a way for the user to
start to boot the computer.</p>
</dd>
<dd>
<p>You must have the <code>&quot;SeRemoteShutdownPrivilege&quot;</code> privilege
on the remote computer for this call to succeed.  If shutting
down the local computer, then the calling process must have
the <code>&quot;SeShutdownPrivilege&quot;</code> privilege and have it enabled.</p>
</dd>
</li>
<dt><strong><a name="item_regclosekey">RegCloseKey</a></strong>

<dt><strong><code>RegCloseKey( $hKey )</code></strong>

<dd>
<p>Closes the handle to a Registry key returned by <a href="#item_regopenkeyex"><code>RegOpenKeyEx()</code></a>,
<a href="#item_regconnectregistry"><code>RegConnectRegistry()</code></a>, <a href="#item_regcreatekeyex"><code>RegCreateKeyEx()</code></a>, or a few other
routines.  Returns a true value if successful and a false value
[and sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.</p>
</dd>
</li>
<dt><strong><a name="item_regconnectregistry">RegConnectRegistry</a></strong>

<dt><strong><code>RegConnectRegistry( $sComputer, $hRootKey, $ohKey )</code></strong>

<dd>
<p>Connects to one of the root Registry keys of a remote computer.
Returns a true value if successful and a false value [and
sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.</p>
</dd>
<dd>
<p><code>$sComputer</code> is the name [or address] of a remote computer
whose Registry you wish to access.</p>
</dd>
<dd>
<p><code>$hKey</code> must be either <code>HKEY_LOCAL_MACHINE</code> or <code>HKEY_USERS</code>
and specifies which root Registry key on the remote computer
you wish to have access to.</p>
</dd>
<dd>
<p><code>$phKey</code> will be set to the handle to be used to access the
remote Registry key if the call succeeds.</p>
</dd>
</li>
<dt><strong><a name="item_regconstant">regConstant</a></strong>

<dt><strong><code>$value= regConstant( $sConstantName )</code></strong>

<dd>
<p>Fetch the value of a constant.  Returns <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if <code>$sConstantName</code>
is not the name of a constant supported by this module.  Never sets
<a href="../../lib/Pod/perlvar.html#item___"><code>$!</code></a> nor <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>.</p>
</dd>
<dd>
<p>This function is rarely used since you will usually get the value of a
constant by having that constant imported into your package by listing
the constant name in the <code>use Win32API::Registry</code> statement and then
simply using the constant name in your code [perhaps followed by
<code>()</code>].  This function is useful for verifying constant names not in
Perl code, for example, after prompting a user to type in a constant
name.</p>
</dd>
</li>
<dt><strong><a name="item_regcreatekey">RegCreateKey</a></strong>

<dt><strong><code>RegCreateKey( $hKey, $sSubKey, $ohSubKey )</code></strong>

<dd>
<p>This routine is meant only for compatibility with Windows version
3.1.  Use <a href="#item_regcreatekeyex"><code>RegCreateKeyEx()</code></a> instead.</p>
</dd>
</li>
<dt><strong><a name="item_regcreatekeyex">RegCreateKeyEx</a></strong>

<dt><strong><code>RegCreateKeyEx( $hKey, $sSubKey, $uZero, $sClass, $uOpts, $uAccess, $pSecAttr, $ohNewKey, $ouDisp )</code></strong>

<dd>
<p>Creates a new Registry subkey.  Returns a true value if successful and
a false value [and sets <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>/<a href="#item_reglasterror"><code>regLastError()</code></a>] on failure.</p>
</dd>
<dd>
<p><code>$hKey</code> is the handle to a Registry key [either <code>HKEY_*</code> or from
a previous call].</p>
</dd>
<dd>
<p><code>$sSubKey</code> is the name of the new subkey to be created.</p>
</dd>
<dd>
<p><code>$iZero</code> is reserved for future use and should always be specified
as <code>0</code>.</p>
</dd>
<dd>
<p><code>$sClass</code> is a string to be used as the class for the new
subkey.  We are not aware of any current use for Registry key
class information so the empty string, <code>&quot;&quot;</code>, should usually
be used here.</p>
</dd>
<dd>
<p><code>$iOpts</code> is a numeric value containing bits that control options
used while creating the new subkey.  <code>REG_OPTION_NON_VOLATILE</code>
is the default.  <code>REG_OPTION_VOLATILE</code> [which is ignored on
Windows 95] means the data stored under this key is not kept
in a file and will not be preserved when the system reboots.
<code>REG_OPTION_BACKUP_RESTORE</code> [also ignored on Windows 95] means
ignore the <code>$iAccess</code> parameter and try to open the new key with
the access required to backup or restore the key.</p>
</dd>
<dd>
<p><code>$iAccess</code> is a numeric mask of bits specifying what type of

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -