📄 file.html
字号:
<p>Requests that a definition be deleted. If <code>$sTargetPath</code> is
<code>[]</code> [for <code>NULL</code>], then the most recently added definition for
<code>$sDosDeviceName</code> is removed. Otherwise the most recently added
definition matching <code>$sTargetPath</code> is removed.</p>
</dd>
<dd>
<p>If the last definition is removed, then the DOS device name is
also deleted.</p>
</dd>
</li>
<dt><strong><a name="item_ddd_exact_match_on_remove"><code>DDD_EXACT_MATCH_ON_REMOVE</code></a></strong>
<dd>
<p>When deleting a definition, this bit causes each <code>$sTargetPath</code> to
be compared to the full-length definition when searching for the most
recently added match. If this bit is not set, then <code>$sTargetPath</code>
only needs to match a prefix of the definition.</p>
</dd>
</li>
</dl>
<p><code>$sTargetPath</code> is the DOS device's specific definition that you
wish to add or delete. For <a href="#item_ddd_raw_target_path"><code>DDD_RAW_TARGET_PATH</code></a>, these usually
start with <code>"\\Device\\"</code>. If the <a href="#item_ddd_raw_target_path"><code>DDD_RAW_TARGET_PATH</code></a> bit is
not set, then <code>$sTargetPath</code> is just an ordinary path to some file
or directory, providing the functionality of the <strong>subst</strong> command.</p>
<dt><strong><a name="item_deletefile">DeleteFile</a></strong>
<dt><strong><code>DeleteFile( $sFileName )</code></strong>
<dd>
<p>Deletes the named file. Compared to Perl's <a href="../../lib/Pod/perlfunc.html#item_unlink"><code>unlink</code></a>, <a href="#item_deletefile"><code>DeleteFile</code></a>
has the advantage of not deleting read-only files. For <strong>some</strong>
versions of Perl, <a href="../../lib/Pod/perlfunc.html#item_unlink"><code>unlink</code></a> silently calls <a href="../../lib/Pod/perlfunc.html#item_chmod"><code>chmod</code></a> whether it needs
to or not before deleting the file so that files that you have
protected by marking them as read-only are not always protected from
Perl's <a href="../../lib/Pod/perlfunc.html#item_unlink"><code>unlink</code></a>.</p>
</dd>
<dd>
<p>Like most 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> and <code>regLastError()</code>] on failure.</p>
</dd>
</li>
<dt><strong><a name="item_deviceiocontrol">DeviceIoControl</a></strong>
<dt><strong><code>DeviceIoControl( $hDevice, $uIoControlCode, $pInBuf, $lInBuf, $opOutBuf, $lOutBuf, $olRetBytes, $pOverlapped )</code></strong>
<dd>
<p>Requests a special operation on an I/O [input/output] device, such
as ejecting a tape or formatting a disk. Like most 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> and
<code>regLastError()</code>] on failure.</p>
</dd>
<dd>
<p><code>$hDevice</code> is a Win32 native file handle to a device [return value
from <a href="#item_createfile"><code>CreateFile</code></a>].</p>
</dd>
<dd>
<p><code>$uIoControlCode</code> is an unsigned value [a <code>IOCTL_*</code> or <code>FSCTL_*</code>
constant] indicating the type query or other operation to be performed.</p>
</dd>
<dd>
<p><code>$pInBuf</code> is <code>[]</code> [for <code>NULL</code>] or a data structure packed into a
string. The type of data structure depends on the <code>$uIoControlCode</code>
value. <code>$lInBuf</code> is <code>0</code> or the length of the structure in
<code>$pInBuf</code>. If <code>$pInBuf</code> is not <code>[]</code> and <code>$lInBuf</code> is <code>0</code>, then
<code>$lInBuf</code> will automatically be set to <a href="../../lib/Pod/perlfunc.html#item_length"><code>length($pInBuf)</code></a> for you.</p>
</dd>
<dd>
<p><code>$opOutBuf</code> is <code>[]</code> [for <code>NULL</code>] or will be set to contain a
returned data structure packed into a string. <code>$lOutBuf</code> indicates
how much space to allocate in <code>$opOutBuf</code> for <a href="#item_deviceiocontrol"><code>DeviceIoControl</code></a> to
store the data structure. If <code>$lOutBuf</code> is a number and <code>$opOutBuf</code>
already has a buffer allocated for it that is larger than <code>$lOutBuf</code>
bytes, then this larger buffer size will be passed to <a href="#item_deviceiocontrol"><code>DeviceIoControl</code></a>.
However, you can force a specific buffer size to be passed to
<a href="#item_deviceiocontrol"><code>DeviceIoControl</code></a> by prepending a <code>"="</code> to the front of <code>$lOutBuf</code>.</p>
</dd>
<dd>
<p><code>$olRetBytes</code> is <code>[]</code> or is a scalar to receive the number of bytes
written to <code>$opOutBuf</code>. Even when <code>$olRetBytes</code> is <code>[]</code>, a valid
pointer to a <code>DWORD</code> [and not <code>NULL</code>] is passed to <a href="#item_deviceiocontrol"><code>DeviceIoControl</code></a>.
In this case, <code>[]</code> just means that you don't care about the value
that might be written to <code>$olRetBytes</code>, which is usually the case
since you can usually use <a href="../../lib/Pod/perlfunc.html#item_length"><code>length($opOutBuf)</code></a> instead.</p>
</dd>
<dd>
<p><code>$pOverlapped</code> is <code>[]</code> or is a <code>OVERLAPPED</code> structure packed into
a string. This is only useful if <code>$hDevice</code> was opened with the
<code>FILE_FLAG_OVERLAPPED</code> flag set.</p>
</dd>
</li>
<dt><strong><a name="item_fdgetosfhandle">FdGetOsFHandle</a></strong>
<dt><strong><code>$hNativeHandle= FdGetOsFHandle( $ivFd )</code></strong>
<dd>
<p><a href="#item_fdgetosfhandle"><code>FdGetOsFHandle</code></a> simply calls <code>_get_osfhandle()</code>. It was renamed
to better fit in with the rest the function names of this module,
in particular to distinguish it from <a href="#item_getosfhandle"><code>GetOsFHandle</code></a>. It takes an
integer file descriptor [as from Perl's <a href="../../lib/Pod/perlfunc.html#item_fileno"><code>fileno</code></a>] and returns the
Win32 native file handle associated with that file descriptor or
<code>INVALID_HANDLE_VALUE</code> if <code>$ivFd</code> is not an open file descriptor.</p>
</dd>
<dd>
<p>When you call Perl's <a href="../../lib/Pod/perlfunc.html#item_open"><code>open</code></a> to set a Perl file handle [like <code>STDOUT</code>],
Perl calls C's <code>fopen</code> to set a stdio <code>FILE *</code>. C's <code>fopen</code> calls
something like Unix's <a href="../../lib/Pod/perlfunc.html#item_open"><code>open</code></a>, that is, Win32's <code>_sopen</code>, to get an
integer file descriptor [where 0 is for <code>STDIN</code>, 1 for <code>STDOUT</code>, etc.].
Win32's <code>_sopen</code> calls <a href="#item_createfile"><code>CreateFile</code></a> to set a <code>HANDLE</code>, a Win32 native
file handle. So every Perl file handle [like <code>STDOUT</code>] has an integer
file descriptor associated with it that you can get via <a href="../../lib/Pod/perlfunc.html#item_fileno"><code>fileno</code></a>. And,
under Win32, every file descriptor has a Win32 native file handle
associated with it. <a href="#item_fdgetosfhandle"><code>FdGetOsFHandle</code></a> lets you get access to that.</p>
</dd>
<dd>
<p><code>$hNativeHandle</code> is set to <code>INVALID_HANDLE_VALUE</code> [and
<code>lastFileError()</code> and <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> are set] if <a href="#item_fdgetosfhandle"><code>FdGetOsFHandle</code></a> fails.
See also <a href="#item_getosfhandle"><code>GetOsFHandle</code></a> which provides a friendlier interface.</p>
</dd>
</li>
<dt><strong><a name="item_fileconstant">fileConstant</a></strong>
<dt><strong><code>$value= fileConstant( $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::File</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_filelasterror">fileLastError</a></strong>
<dt><strong><code>$svError= fileLastError();</code></strong>
<dt><strong><code>fileLastError( $uError );</code></strong>
<dd>
<p>Returns the last error encountered by a routine from this module.
It is just like <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> except it isn't changed by anything except
routines from this module. Ideally you could just use <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>, but
current versions of Perl often overwrite <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> before you get a
chance to check it and really old versions of Perl don't really
support <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a> under Win32.</p>
</dd>
<dd>
<p>Just like <a href="../../lib/Pod/perlvar.html#item___e"><code>$^E</code></a>, in a numeric context <a href="#item_filelasterror"><code>fileLastError()</code></a> returns
the numeric error value while in a string context it returns a
text description of the error [actually it returns a Perl scalar
that contains both values so <a href="#item_filelasterror"><code>$x= fileLastError()</code></a> causes <code>$x</code>
to give different values in string vs. numeric contexts].</p>
</dd>
<dd>
<p>The last form sets the error returned by future calls to
<a href="#item_filelasterror"><code>fileLastError()</code></a> and should not be used often. <code>$uError</code> must
be a numeric error code. Also returns the dual-valued version
of <code>$uError</code>.</p>
</dd>
</li>
<dt><strong><a name="item_getdrivetype">GetDriveType</a></strong>
<dt><strong><code>$uDriveType= GetDriveType( $sRootPath )</code></strong>
<dd>
<p>Takes a string giving the path to the root directory of a file system
[called a "drive" because every file system is assigned a "drive letter"]
and returns an unsigned value indicating the type of drive the file
system is on. The return value should be one of:</p>
</dd>
<dl>
<dt><strong><a name="item_drive_unknown"><code>DRIVE_UNKNOWN</code></a></strong>
<dd>
<p>None of the following.</p>
</dd>
</li>
<dt><strong><a name="item_drive_no_root_dir"><code>DRIVE_NO_ROOT_DIR</code></a></strong>
<dd>
<p>A "drive" that does not have a file system. This can be a drive letter
that hasn't been defined or a drive letter assigned to a partition
that hasn't been formatted yet.</p>
</dd>
</li>
<dt><strong><a name="item_drive_removable"><code>DRIVE_REMOVABLE</code></a></strong>
<dd>
<p>A floppy diskette drive or other removable media drive, but not a CD-ROM
drive.</p>
</dd>
</li>
<dt><strong><a name="item_drive_fixed"><code>DRIVE_FIXED</code></a></strong>
<dd>
<p>An ordinary hard disk partition.</p>
</dd>
</li>
<dt><strong><a name="item_drive_remote"><code>DRIVE_REMOTE</code></a></strong>
<dd>
<p>A network share.</p>
</dd>
</li>
<dt><strong><a name="item_drive_cdrom"><code>DRIVE_CDROM</code></a></strong>
<dd>
<p>A CD-ROM drive.</p>
</dd>
</li>
<dt><strong><a name="item_drive_ramdisk"><code>DRIVE_RAMDISK</code></a></strong>
<dd>
<p>A "ram disk" or memory-resident virtual file system used for high-speed
access to small amounts of temporary file space.</p>
</dd>
</li>
</dl>
<dt><strong><a name="item_getfileattributes">GetFileAttributes</a></strong>
<dt><strong><code>$uAttrs = GetFileAttributes( $sPath )</code></strong>
<dd>
<p>Takes a path string and returns an unsigned value with attribute flags.
If it fails, it returns INVALID_FILE_ATTRIBUTES, otherwise it can be
one or more of the following values:</p>
</dd>
<dl>
<dt><strong><a name="item_file_attribute_archive"><code>FILE_ATTRIBUTE_ARCHIVE</code></a></strong>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -