eventlog.html
来自「perl教程」· HTML 代码 · 共 340 行 · 第 1/2 页
HTML
340 行
<?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>Win32::EventLog - Process Win32 Event Logs from Perl</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>Win32::EventLog - Process Win32 Event Logs from Perl</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>
<li><a href="#the_eventlog_object_and_its_methods">The EventLog Object and its Methods</a></li>
<li><a href="#other_win32__eventlog_functions_">Other Win32::EventLog functions.</a></li>
<li><a href="#example_1">Example 1</a></li>
<li><a href="#example_2">Example 2</a></li>
<li><a href="#bugs">BUGS</a></li>
<li><a href="#author">AUTHOR</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32::EventLog - Process Win32 Event Logs from Perl</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">Win32::EventLog</span>
<span class="variable">$handle</span><span class="operator">=</span><span class="variable">Win32::EventLog</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span class="string">"Application"</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module implements most of the functionality available from the
Win32 API for accessing and manipulating Win32 Event Logs. The access
to the EventLog routines is divided into those that relate to an
EventLog object and its associated methods and those that relate other
EventLog tasks (like adding an EventLog record).</p>
<p>
</p>
<hr />
<h1><a name="the_eventlog_object_and_its_methods">The EventLog Object and its Methods</a></h1>
<p>The following methods are available to open, read, close and backup
EventLogs.</p>
<dl>
<dt><strong><a name="item_new">Win32::EventLog->new(SOURCENAME [,SERVERNAME]);</a></strong>
<dd>
<p>The <a href="#item_new"><code>new()</code></a> method creates a new EventLog object and returns a handle
to it. This hande is then used to call the methods below.</p>
</dd>
<dd>
<p>The method is overloaded in that if the supplied SOURCENAME
argument contains one or more literal '\' characters (an illegal
character in a SOURCENAME), it assumes that you are trying to open
a backup eventlog and uses SOURCENAME as the backup eventlog to
open. Note that when opening a backup eventlog, the SERVERNAME
argument is ignored (as it is in the underlying Win32 API). For
EventLogs on remote machines, the SOURCENAME parameter must
therefore be specified as a UNC path.</p>
</dd>
</li>
<dt><strong><a name="item_backup">$handle->Backup(FILENAME);</a></strong>
<dd>
<p>The <a href="#item_backup"><code>Backup()</code></a> method backs up the EventLog represented by $handle. It
takes a single arguemt, FILENAME. When $handle represents an
EventLog on a remote machine, FILENAME is filename on the remote
machine and cannot be a UNC path (i.e you must use <em>C:\TEMP\App.EVT</em>).
The method will fail if the log file already exists.</p>
</dd>
</li>
<dt><strong><a name="item_read">$handle->Read(FLAGS, OFFSET, HASHREF);</a></strong>
<dd>
<p>The <a href="#item_read"><code>Read()</code></a> method read an EventLog entry from the EventLog represented
by $handle.</p>
</dd>
</li>
<dt><strong><a name="item_close">$handle->Close();</a></strong>
<dd>
<p>The <a href="#item_close"><code>Close()</code></a> method closes the EventLog represented by $handle. After
<a href="#item_close"><code>Close()</code></a> has been called, any further attempt to use the EventLog
represented by $handle will fail.</p>
</dd>
</li>
<dt><strong><a name="item_getoldest">$handle->GetOldest(SCALARREF);</a></strong>
<dd>
<p>The <a href="#item_getoldest"><code>GetOldest()</code></a> method number of the the oldest EventLog record in
the EventLog represented by $handle. This is required to correctly
compute the OFFSET required by the <a href="#item_read"><code>Read()</code></a> method.</p>
</dd>
</li>
<dt><strong><a name="item_getnumber">$handle->GetNumber(SCALARREF);</a></strong>
<dd>
<p>The <a href="#item_getnumber"><code>GetNumber()</code></a> method returns the number of EventLog records in
the EventLog represented by $handle. The number of the most recent
record in the EventLog is therefore computed by</p>
</dd>
<dd>
<pre>
<span class="variable">$handle</span><span class="operator">-></span><span class="variable">GetOldest</span><span class="operator">(</span><span class="variable">$oldest</span><span class="operator">);</span>
<span class="variable">$handle</span><span class="operator">-></span><span class="variable">GetNumber</span><span class="operator">(</span><span class="variable">$lastRec</span><span class="operator">);</span>
<span class="variable">$lastRecOffset</span><span class="operator">=</span><span class="variable">$oldest</span><span class="operator">+</span><span class="variable">$lastRec</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_clear">$handle->Clear(FILENAME);</a></strong>
<dd>
<p>The <a href="#item_clear"><code>Clear()</code></a> method clears the EventLog represented by $handle. If
you provide a non-null FILENAME, the EventLog will be backed up
into FILENAME before the EventLog is cleared. The method will fail
if FILENAME is specified and the file refered to exists. Note also
that FILENAME specifies a file local to the machine on which the
EventLog resides and cannot be specified as a UNC name.</p>
</dd>
</li>
<dt><strong><a name="item_report">$handle->Report(HASHREF);</a></strong>
<dd>
<p>The <a href="#item_report"><code>Report()</code></a> method generates an EventLog entry. The HASHREF should
contain the following keys:</p>
</dd>
<dl>
<dt><strong><a name="item_computer"><code>Computer</code></a></strong>
<dd>
<p>The <a href="#item_computer"><code>Computer</code></a> field specfies which computer you want the EventLog
entry recorded. If this key doesn't exist, the server name used to
create the $handle is used.</p>
</dd>
</li>
<dt><strong><a name="item_source"><code>Source</code></a></strong>
<dd>
<p>The <a href="#item_source"><code>Source</code></a> field specifies the source that generated the EventLog
entry. If this key doesn't exist, the source name used to create the
$handle is used.</p>
</dd>
</li>
<dt><strong><a name="item_eventtype"><code>EventType</code></a></strong>
<dd>
<p>The <a href="#item_eventtype"><code>EventType</code></a> field should be one of the constants</p>
</dd>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?