win32.html

来自「perl教程」· HTML 代码 · 共 667 行 · 第 1/2 页

HTML
667 行
字号
<?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 - Interfaces to some Win32 API Functions</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__',1);</script>
<h1><a>Win32 - Interfaces to some Win32 API Functions</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

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

		<li><a href="#alphabetical_listing_of_win32_functions">Alphabetical Listing of Win32 Functions</a></li>
	</ul>

</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32 - Interfaces to some Win32 API Functions</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>Perl on Win32 contains several functions to access Win32 APIs.  Some
are included in Perl itself (on Win32) and some are only available
after explicitly requesting the Win32 module with:</p>
<pre>
        <span class="keyword">use</span> <span class="variable">Win32</span><span class="operator">;</span>
</pre>
<p>The builtin functions are marked as [CORE] and the other ones
as [EXT] in the following alphabetical listing.</p>
<p>
</p>
<h2><a name="alphabetical_listing_of_win32_functions">Alphabetical Listing of Win32 Functions</a></h2>
<dl>
<dt><strong><a name="item_abortsystemshutdown">Win32::AbortSystemShutdown(MACHINE)</a></strong>

<dd>
<p>[EXT] Aborts a system shutdown (started by the
InitiateSystemShutdown function) on the specified MACHINE.</p>
</dd>
</li>
<dt><strong><a name="item_buildnumber">Win32::BuildNumber()</a></strong>

<dd>
<p>[CORE] Returns the ActivePerl build number.  This function is
only available in the ActivePerl binary distribution.</p>
</dd>
</li>
<dt><strong><a name="item_copyfile">Win32::CopyFile(FROM, TO, OVERWRITE)</a></strong>

<dd>
<p>[CORE] The Win32::CopyFile() function copies an existing file to a new
file.  All file information like creation time and file attributes will
be copied to the new file.  However it will <strong>not</strong> copy the security
information.  If the destination file already exists it will only be
overwritten when the OVERWRITE parameter is true.  But even this will
not overwrite a read-only file; you have to <a href="../lib/Pod/perlfunc.html#item_unlink"><code>unlink()</code></a> it first
yourself.</p>
</dd>
</li>
<dt><strong><a name="item_domainname">Win32::DomainName()</a></strong>

<dd>
<p>[CORE] Returns the name of the Microsoft Network domain that the
owner of the current perl process is logged into.  This function does
<strong>not</strong> work on Windows 9x.</p>
</dd>
</li>
<dt><strong><a name="item_expandenvironmentstrings">Win32::ExpandEnvironmentStrings(STRING)</a></strong>

<dd>
<p>[EXT] Takes STRING and replaces all referenced environment variable
names with their defined values.  References to environment variables
take the form <code>%VariableName%</code>.  Case is ignored when looking up the
VariableName in the environment.  If the variable is not found then the
original <code>%VariableName%</code> text is retained.  Has the same effect
as the following:</p>
</dd>
<dd>
<pre>
        <span class="variable">$string</span> <span class="operator">=~</span> <span class="regex">s/%([^%]*)%/$ENV{$1} || "%$1%"/eg</span>
</pre>
</dd>
<dd>
<p>This function may return a Unicode string if the environment
variable being expanded hasn't been assigned to via %ENV.  Access
to %ENV is currently always using byte semantics.</p>
</dd>
</li>
<dt><strong><a name="item_formatmessage">Win32::FormatMessage(ERRORCODE)</a></strong>

<dd>
<p>[CORE] Converts the supplied Win32 error number (e.g. returned by
Win32::GetLastError()) to a descriptive string.  Analogous to the
<code>perror()</code> standard-C library function.  Note that <a href="../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> used
in a string context has much the same effect.</p>
</dd>
<dd>
<pre>
        <span class="variable">C</span><span class="operator">:\&gt;</span> <span class="variable">perl</span> <span class="keyword">-e</span> <span class="string">"$^E = 26; print $^E;"</span>
        <span class="variable">The</span> <span class="variable">specified</span> <span class="variable">disk</span> <span class="keyword">or</span> <span class="variable">diskette</span> <span class="variable">cannot</span> <span class="variable">be</span> <span class="variable">accessed</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_fstype">Win32::FsType()</a></strong>

<dd>
<p>[CORE] Returns the name of the filesystem of the currently active
drive (like 'FAT' or 'NTFS').  In list context it returns three values:
(FSTYPE, FLAGS, MAXCOMPLEN).  FSTYPE is the filesystem type as
before.  FLAGS is a combination of values of the following table:</p>
</dd>
<dd>
<pre>
        0x00000001  supports case-sensitive filenames
        0x00000002  preserves the case of filenames
        0x00000004  supports Unicode in filenames
        0x00000008  preserves and enforces ACLs
        0x00000010  supports file-based compression
        0x00000020  supports disk quotas
        0x00000040  supports sparse files
        0x00000080  supports reparse points
        0x00000100  supports remote storage
        0x00008000  is a compressed volume (e.g. DoubleSpace)
        0x00010000  supports object identifiers
        0x00020000  supports the Encrypted File System (EFS)</pre>
</dd>
<dd>
<p>MAXCOMPLEN is the maximum length of a filename component (the part
between two backslashes) on this file system.</p>
</dd>
</li>
<dt><strong><a name="item_freelibrary">Win32::FreeLibrary(HANDLE)</a></strong>

<dd>
<p>[EXT] Unloads a previously loaded dynamic-link library.  The HANDLE is
no longer valid after this call.  See <a href="../Win32/LoadLibrary(LIBNAME).html">LoadLibrary</a>
for information on dynamically loading a library.</p>
</dd>
</li>
<dt><strong><a name="item_getansipathname">Win32::GetANSIPathName(FILENAME)</a></strong>

<dd>
<p>[EXT] Returns an ANSI version of FILENAME.  This may be the short name
if the long name cannot be represented in the system codepage.</p>
</dd>
<dd>
<p>While not currently implemented, it is possible that in the future
this function will convert only parts of the path to FILENAME to a
short form.</p>
</dd>
<dd>
<p>If FILENAME doesn't exist on the filesystem, or if the filesystem
doesn't support short ANSI filenames, then this function will
translate the Unicode name into the system codepage using replacement
characters.</p>
</dd>
</li>
<dt><strong><a name="item_getarchname">Win32::GetArchName()</a></strong>

<dd>
<p>[EXT] Use of this function is deprecated.  It is equivalent with
$ENV{PROCESSOR_ARCHITECTURE}.  This might not work on Win9X.</p>
</dd>
</li>
<dt><strong><a name="item_getchipname">Win32::GetChipName()</a></strong>

<dd>
<p>[EXT] Returns the processor type: 386, 486 or 586 for Intel processors,
21064 for the Alpha chip.</p>
</dd>
</li>
<dt><strong><a name="item_getcwd">Win32::GetCwd()</a></strong>

<dd>
<p>[CORE] Returns the current active drive and directory.  This function
does not return a UNC path, since the functionality required for such
a feature is not available under Windows 95.</p>
</dd>
<dd>
<p>If supported by the core Perl version, this function will return an
ANSI path name for the current directory if the long pathname cannot
be represented in the system codepage.</p>
</dd>
</li>
<dt><strong><a name="item_getfileversion">Win32::GetFileVersion(FILENAME)</a></strong>

<dd>
<p>[EXT] Returns the file version number from the VERSIONINFO resource of
the executable file or DLL.  This is a tuple of four 16 bit numbers.
In list context these four numbers will be returned.  In scalar context
they are concatenated into a string, separated by dots.</p>
</dd>
</li>
<dt><strong><a name="item_getfolderpath">Win32::GetFolderPath(FOLDER [, CREATE])</a></strong>

<dd>
<p>[EXT] Returns the full pathname of one of the Windows special folders.
The folder will be created if it doesn't exist and the optional CREATE
argument is true.  The following FOLDER constants are defined by the
Win32 module, but only exported on demand:</p>
</dd>
<dd>
<pre>
        CSIDL_ADMINTOOLS
        CSIDL_APPDATA
        CSIDL_CDBURN_AREA
        CSIDL_COMMON_ADMINTOOLS
        CSIDL_COMMON_APPDATA
        CSIDL_COMMON_DESKTOPDIRECTORY
        CSIDL_COMMON_DOCUMENTS
        CSIDL_COMMON_FAVORITES
        CSIDL_COMMON_MUSIC
        CSIDL_COMMON_PICTURES
        CSIDL_COMMON_PROGRAMS
        CSIDL_COMMON_STARTMENU
        CSIDL_COMMON_STARTUP
        CSIDL_COMMON_TEMPLATES
        CSIDL_COMMON_VIDEO
        CSIDL_COOKIES
        CSIDL_DESKTOP
        CSIDL_DESKTOPDIRECTORY
        CSIDL_FAVORITES
        CSIDL_FONTS
        CSIDL_HISTORY
        CSIDL_INTERNET_CACHE
        CSIDL_LOCAL_APPDATA
        CSIDL_MYMUSIC
        CSIDL_MYPICTURES
        CSIDL_MYVIDEO
        CSIDL_NETHOOD
        CSIDL_PERSONAL
        CSIDL_PRINTHOOD
        CSIDL_PROFILE
        CSIDL_PROGRAMS
        CSIDL_PROGRAM_FILES
        CSIDL_PROGRAM_FILES_COMMON
        CSIDL_RECENT
        CSIDL_RESOURCES
        CSIDL_RESOURCES_LOCALIZED
        CSIDL_SENDTO
        CSIDL_STARTMENU
        CSIDL_STARTUP
        CSIDL_SYSTEM
        CSIDL_TEMPLATES
        CSIDL_WINDOWS</pre>
</dd>
<dd>
<p>Note that not all folders are defined on all versions of Windows.</p>
</dd>
<dd>
<p>Please refer to the MSDN documentation of the CSIDL constants,
currently available at:</p>
</dd>
<dd>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp</a></p>
</dd>
<dd>
<p>This function will return an ANSI folder path if the long name cannot
be represented in the system codepage.  Use Win32::GetLongPathName()
on the result of Win32::GetFolderPath() if you want the Unicode
version of the folder name.</p>
</dd>
</li>
<dt><strong><a name="item_getfullpathname">Win32::GetFullPathName(FILENAME)</a></strong>

<dd>
<p>[CORE] GetFullPathName combines the FILENAME with the current drive
and directory name and returns a fully qualified (aka, absolute)
path name.  In list context it returns two elements: (PATH, FILE) where
PATH is the complete pathname component (including trailing backslash)
and FILE is just the filename part.  Note that no attempt is made to
convert 8.3 components in the supplied FILENAME to longnames or
vice-versa.  Compare with Win32::GetShortPathName() and
Win32::GetLongPathName().</p>
</dd>
<dd>
<p>If supported by the core Perl version, this function will return an
ANSI path name if the full pathname cannot be represented in the
system codepage.</p>
</dd>
</li>
<dt><strong><a name="item_getlasterror">Win32::GetLastError()</a></strong>

<dd>
<p>[CORE] Returns the last error value generated by a call to a Win32 API
function.  Note that <a href="../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> used in a numeric context amounts to the
same value.</p>
</dd>
</li>
<dt><strong><a name="item_getlongpathname">Win32::GetLongPathName(PATHNAME)</a></strong>

<dd>
<p>[CORE] Returns a representation of PATHNAME composed of longname
components (if any).  The result may not necessarily be longer
than PATHNAME.  No attempt is made to convert PATHNAME to the
absolute path.  Compare with Win32::GetShortPathName() and
Win32::GetFullPathName().</p>
</dd>
<dd>
<p>This function may return the pathname in Unicode if it cannot be
represented in the system codepage.  Use Win32::GetANSIPathName()
before passing the path to a system call or another program.</p>
</dd>
</li>
<dt><strong><a name="item_getnextavaildrive">Win32::GetNextAvailDrive()</a></strong>

<dd>
<p>[CORE] Returns a string in the form of &quot;&lt;d&gt;:&quot; where &lt;d&gt; is the first
available drive letter.</p>
</dd>
</li>

⌨️ 快捷键说明

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