<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># File.pm -- Low-level access to Win32 file/dir functions/constants.

package Win32API::File;

use strict;
use integer;
use Carp;
use Config qw( %Config );
use Fcntl qw( O_RDONLY O_RDWR O_WRONLY O_APPEND O_BINARY O_TEXT );
use vars qw( $VERSION @ISA );
use vars qw( @EXPORT @EXPORT_OK @EXPORT_FAIL %EXPORT_TAGS );

$VERSION= '0.1203_01';

use base qw( Exporter DynaLoader Tie::Handle IO::File );

# Math::BigInt optimizations courtesy of Tels
my $_64BITINT;
BEGIN {
    $_64BITINT = defined($Config{use64bitint}) &amp;&amp;
                 ($Config{use64bitint} eq 'define');

    require Math::BigInt unless $_64BITINT;
}

my $THIRTY_TWO = $_64BITINT ? 32 : Math::BigInt-&gt;new(32);

my $FFFFFFFF   = $_64BITINT ? 0xFFFFFFFF : Math::BigInt-&gt;new(0xFFFFFFFF);

@EXPORT= qw();
%EXPORT_TAGS= (
    Func =&gt;	[qw(		attrLetsToBits		createFile
    	fileConstant		fileLastError		getLogicalDrives
	CloseHandle		CopyFile		CreateFile
	DefineDosDevice		DeleteFile		DeviceIoControl
	FdGetOsFHandle		GetDriveType		GetFileAttributes		GetFileType
	GetHandleInformation	GetLogicalDrives	GetLogicalDriveStrings
	GetOsFHandle		GetVolumeInformation	IsRecognizedPartition
	IsContainerPartition	MoveFile		MoveFileEx
	OsFHandleOpen		OsFHandleOpenFd		QueryDosDevice
	ReadFile		SetErrorMode		SetFilePointer
	SetHandleInformation	WriteFile		GetFileSize
	getFileSize		setFilePointer		GetOverlappedResult)],
    FuncA =&gt;	[qw(
	CopyFileA		CreateFileA		DefineDosDeviceA
	DeleteFileA		GetDriveTypeA		GetFileAttributesA		GetLogicalDriveStringsA
	GetVolumeInformationA	MoveFileA		MoveFileExA
	QueryDosDeviceA )],
    FuncW =&gt;	[qw(
	CopyFileW		CreateFileW		DefineDosDeviceW
	DeleteFileW		GetDriveTypeW		GetFileAttributesW		GetLogicalDriveStringsW
	GetVolumeInformationW	MoveFileW		MoveFileExW
	QueryDosDeviceW )],
    Misc =&gt;		[qw(
	CREATE_ALWAYS		CREATE_NEW		FILE_BEGIN
	FILE_CURRENT		FILE_END		INVALID_HANDLE_VALUE
	OPEN_ALWAYS		OPEN_EXISTING		TRUNCATE_EXISTING )],
    DDD_ =&gt;	[qw(
	DDD_EXACT_MATCH_ON_REMOVE			DDD_RAW_TARGET_PATH
	DDD_REMOVE_DEFINITION )],
    DRIVE_ =&gt;	[qw(
	DRIVE_UNKNOWN		DRIVE_NO_ROOT_DIR	DRIVE_REMOVABLE
	DRIVE_FIXED		DRIVE_REMOTE		DRIVE_CDROM
	DRIVE_RAMDISK )],
    FILE_ =&gt;	[qw(
	FILE_READ_DATA			FILE_LIST_DIRECTORY
	FILE_WRITE_DATA			FILE_ADD_FILE
	FILE_APPEND_DATA		FILE_ADD_SUBDIRECTORY
	FILE_CREATE_PIPE_INSTANCE	FILE_READ_EA
	FILE_WRITE_EA			FILE_EXECUTE
	FILE_TRAVERSE			FILE_DELETE_CHILD
	FILE_READ_ATTRIBUTES		FILE_WRITE_ATTRIBUTES
	FILE_ALL_ACCESS			FILE_GENERIC_READ
	FILE_GENERIC_WRITE		FILE_GENERIC_EXECUTE )],
    FILE_ATTRIBUTE_ =&gt;	[qw(
    INVALID_FILE_ATTRIBUTES
    FILE_ATTRIBUTE_DEVICE        FILE_ATTRIBUTE_DIRECTORY
    FILE_ATTRIBUTE_ENCRYPTED     FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
    FILE_ATTRIBUTE_REPARSE_POINT FILE_ATTRIBUTE_SPARSE_FILE
	FILE_ATTRIBUTE_ARCHIVE		 FILE_ATTRIBUTE_COMPRESSED
	FILE_ATTRIBUTE_HIDDEN		 FILE_ATTRIBUTE_NORMAL
	FILE_ATTRIBUTE_OFFLINE		 FILE_ATTRIBUTE_READONLY
	FILE_ATTRIBUTE_SYSTEM		 FILE_ATTRIBUTE_TEMPORARY )],
    FILE_FLAG_ =&gt;	[qw(
	FILE_FLAG_BACKUP_SEMANTICS	FILE_FLAG_DELETE_ON_CLOSE
	FILE_FLAG_NO_BUFFERING		FILE_FLAG_OVERLAPPED
	FILE_FLAG_POSIX_SEMANTICS	FILE_FLAG_RANDOM_ACCESS
	FILE_FLAG_SEQUENTIAL_SCAN	FILE_FLAG_WRITE_THROUGH
	FILE_FLAG_OPEN_REPARSE_POINT )],
    FILE_SHARE_ =&gt;	[qw(
	FILE_SHARE_DELETE	FILE_SHARE_READ		FILE_SHARE_WRITE )],
    FILE_TYPE_ =&gt;	[qw(
	FILE_TYPE_CHAR		FILE_TYPE_DISK		FILE_TYPE_PIPE
	FILE_TYPE_UNKNOWN )],
    FS_ =&gt;	[qw(
	FS_CASE_IS_PRESERVED		FS_CASE_SENSITIVE
	FS_UNICODE_STORED_ON_DISK	FS_PERSISTENT_ACLS 
	FS_FILE_COMPRESSION		FS_VOL_IS_COMPRESSED )],
	FSCTL_ =&gt; [qw(
	FSCTL_SET_REPARSE_POINT		FSCTL_GET_REPARSE_POINT
	FSCTL_DELETE_REPARSE_POINT )],
    HANDLE_FLAG_ =&gt;	[qw(
	HANDLE_FLAG_INHERIT		HANDLE_FLAG_PROTECT_FROM_CLOSE )],
    IOCTL_STORAGE_ =&gt;	[qw(
	IOCTL_STORAGE_CHECK_VERIFY	IOCTL_STORAGE_MEDIA_REMOVAL
	IOCTL_STORAGE_EJECT_MEDIA	IOCTL_STORAGE_LOAD_MEDIA
	IOCTL_STORAGE_RESERVE		IOCTL_STORAGE_RELEASE
	IOCTL_STORAGE_FIND_NEW_DEVICES	IOCTL_STORAGE_GET_MEDIA_TYPES
	)],
    IOCTL_DISK_ =&gt;	[qw(
	IOCTL_DISK_FORMAT_TRACKS	IOCTL_DISK_FORMAT_TRACKS_EX
	IOCTL_DISK_GET_DRIVE_GEOMETRY	IOCTL_DISK_GET_DRIVE_LAYOUT
	IOCTL_DISK_GET_MEDIA_TYPES	IOCTL_DISK_GET_PARTITION_INFO
	IOCTL_DISK_HISTOGRAM_DATA	IOCTL_DISK_HISTOGRAM_RESET
	IOCTL_DISK_HISTOGRAM_STRUCTURE	IOCTL_DISK_IS_WRITABLE
	IOCTL_DISK_LOGGING		IOCTL_DISK_PERFORMANCE
	IOCTL_DISK_REASSIGN_BLOCKS	IOCTL_DISK_REQUEST_DATA
	IOCTL_DISK_REQUEST_STRUCTURE	IOCTL_DISK_SET_DRIVE_LAYOUT
	IOCTL_DISK_SET_PARTITION_INFO	IOCTL_DISK_VERIFY )],
    GENERIC_ =&gt;		[qw(
	GENERIC_ALL			GENERIC_EXECUTE
	GENERIC_READ			GENERIC_WRITE )],
    MEDIA_TYPE =&gt;	[qw(
	Unknown			F5_1Pt2_512		F3_1Pt44_512
	F3_2Pt88_512		F3_20Pt8_512		F3_720_512
	F5_360_512		F5_320_512		F5_320_1024
	F5_180_512		F5_160_512		RemovableMedia
	FixedMedia		F3_120M_512 )],
    MOVEFILE_ =&gt;	[qw(
	MOVEFILE_COPY_ALLOWED		MOVEFILE_DELAY_UNTIL_REBOOT
	MOVEFILE_REPLACE_EXISTING	MOVEFILE_WRITE_THROUGH )],
    SECURITY_ =&gt;	[qw(
	SECURITY_ANONYMOUS		SECURITY_CONTEXT_TRACKING
	SECURITY_DELEGATION		SECURITY_EFFECTIVE_ONLY
	SECURITY_IDENTIFICATION		SECURITY_IMPERSONATION
	SECURITY_SQOS_PRESENT )],
    SEM_ =&gt;		[qw(
	SEM_FAILCRITICALERRORS		SEM_NOGPFAULTERRORBOX
	SEM_NOALIGNMENTFAULTEXCEPT	SEM_NOOPENFILEERRORBOX )],
    PARTITION_ =&gt;	[qw(
	PARTITION_ENTRY_UNUSED		PARTITION_FAT_12
	PARTITION_XENIX_1		PARTITION_XENIX_2
	PARTITION_FAT_16		PARTITION_EXTENDED
	PARTITION_HUGE			PARTITION_IFS
	PARTITION_FAT32			PARTITION_FAT32_XINT13
	PARTITION_XINT13		PARTITION_XINT13_EXTENDED
	PARTITION_PREP			PARTITION_UNIX
	VALID_NTFT			PARTITION_NTFT )],
    STD_HANDLE_ =&gt;		[qw(
	STD_INPUT_HANDLE		STD_OUTPUT_HANDLE
	STD_ERROR_HANDLE )],
);
@EXPORT_OK= ();
{
    my $key;
    foreach $key (  keys(%EXPORT_TAGS)  ) {
	push( @EXPORT_OK, @{$EXPORT_TAGS{$key}} );
	#push( @EXPORT_FAIL, @{$EXPORT_TAGS{$key}} )   unless  $key =~ /^Func/;
    }
}
$EXPORT_TAGS{ALL}= \@EXPORT_OK;

bootstrap Win32API::File $VERSION;

# Preloaded methods go here.

# To convert C constants to Perl code in cFile.pc
# [instead of C or C++ code in cFile.h]:
#    * Modify F&lt;Makefile.PL&gt; to add WriteMakeFile() =&gt;
#      CONST2PERL/postamble =&gt; [[ "Win32API::File" =&gt; ]] WRITE_PERL =&gt; 1.
#    * Either comment out C&lt;#include "cFile.h"&gt; from F&lt;File.xs&gt;
#      or make F&lt;cFile.h&gt; an empty file.
#    * Make sure the following C&lt;if&gt; block is not commented out.
#    * "nmake clean", "perl Makefile.PL", "nmake"

if(  ! defined &amp;GENERIC_READ  ) {
    require "Win32API/File/cFile.pc";
}

sub fileConstant
{
    my( $name )= @_;
    if(  1 != @_  ||  ! $name  ||  $name =~ /\W/  ) {
	require Carp;
	Carp::croak( 'Usage: ',__PACKAGE__,'::fileConstant("CONST_NAME")' );
    }
    my $proto= prototype $name;
    if(  defined \&amp;$name
     &amp;&amp;  defined $proto
     &amp;&amp;  "" eq $proto  ) {
	no strict 'refs';
	return &amp;$name;
    }
    return undef;
}

# We provide this for backwards compatibility:
sub constant
{
    my( $name )= @_;
    my $value= fileConstant( $name );
    if(  defined $value  ) {
	$!= 0;
	return $value;
    }
    $!= 11; # EINVAL
    return 0;
}

# BEGIN {
#     my $code= 'return _fileLastError(@_)';
#     local( $!, $^E )= ( 1, 1 );
#     if(  $! ne $^E  ) {
# 	$code= '
# 	    local( $^E )= _fileLastError(@_);
# 	    my $ret= $^E;
# 	    return $ret;
# 	';
#     }
#     eval "sub fileLastError { $code }";
#     die "$@"   if  $@;
# }

package Win32API::File::_error;

use overload
    '""' =&gt; sub {
	require Win32 unless defined &amp;Win32::FormatMessage;
	$_ = Win32::FormatMessage(Win32API::File::_fileLastError());
	tr/\r\n//d;
	return $_;
    },
    '0+' =&gt; sub { Win32API::File::_fileLastError() },
    'fallback' =&gt; 1;

sub new { return bless {}, shift }
sub set { Win32API::File::_fileLastError($_[1]); return $_[0] }

package Win32API::File;

my $_error = Win32API::File::_error-&gt;new();

sub fileLastError {
    croak 'Usage: ',__PACKAGE__,'::fileLastError( [$setWin32ErrCode] )'	if @_ &gt; 1;
    $_error-&gt;set($_[0]) if defined $_[0];
    return $_error;
}

# Since we ISA DynaLoader which ISA AutoLoader, we ISA AutoLoader so we
# need this next chunk to prevent Win32API::File-&gt;nonesuch() from
# looking for "nonesuch.al" and producing confusing error messages:
use vars qw($AUTOLOAD);
sub AUTOLOAD {
    require Carp;
    Carp::croak(
      "Can't locate method $AUTOLOAD via package Win32API::File" );
}

# Replace "&amp;rout;" with "goto &amp;rout;" when that is supported on Win32.

# Aliases for non-Unicode functions:
sub CopyFile			{ &amp;CopyFileA; }
sub CreateFile			{ &amp;CreateFileA; }
sub DefineDosDevice		{ &amp;DefineDosDeviceA; }
sub DeleteFile			{ &amp;DeleteFileA; }
sub GetDriveType		{ &amp;GetDriveTypeA; }
sub GetFileAttributes	{ &amp;GetFileAttributesA; }
sub GetLogicalDriveStrings	{ &amp;GetLogicalDriveStringsA; }
sub GetVolumeInformation	{ &amp;GetVolumeInformationA; }
sub MoveFile			{ &amp;MoveFileA; }
sub MoveFileEx			{ &amp;MoveFileExA; }
sub QueryDosDevice		{ &amp;QueryDosDeviceA; }

sub OsFHandleOpen {
    if(  3 != @_  ) {
	croak 'Win32API::File Usage:  ',
	      'OsFHandleOpen(FILE,$hNativeHandle,"rwatb")';
    }
    my( $fh, $osfh, $access )= @_;
    if(  ! ref($fh)  ) {
	if(  $fh !~ /('|::)/  ) {
	    $fh= caller() . "::" . $fh;
	}
	no strict "refs";
	$fh= \*{$fh};
    }
    my( $mode, $pref );
    if(  $access =~ /r/i  ) {
	if(  $access =~ /w/i  ) {
	    $mode= O_RDWR;
	    $pref= "+&lt;";
	} else {
	    $mode= O_RDONLY;
	    $pref= "&lt;";
	}
    } else {
	if(  $access =~ /w/i  ) {
	    $mode= O_WRONLY;
	    $pref= "&gt;";
	} else {
	#   croak qq&lt;Win32API::File::OsFHandleOpen():  &gt;,
	#	  qq&lt;Access ($access) missing both "r" and "w"&gt;;
	    $mode= O_RDONLY;
	    $pref= "&lt;";
	}
    }
    $mode |= O_APPEND   if  $access =~ /a/i;
    #$mode |= O_TEXT   if  $access =~ /t/i;
    # Some versions of the Fcntl module are broken and won't autoload O_TEXT:
    if(  $access =~ /t/i  ) {
	my $o_text= eval "O_TEXT";
	$o_text= 0x4000   if  $@;
	$mode |= $o_text;
    }
    $mode |= O_BINARY   if  $access =~ /b/i;
    my $fd = eval { OsFHandleOpenFd( $osfh, $mode ) };
    if ($@) {
	return tie *{$fh}, __PACKAGE__, $osfh;
    }
    return  undef unless  $fd;
    return  open( $fh, $pref."&amp;=".(0+$fd) );
}

sub GetOsFHandle {
    if(  1 != @_  ) {
	croak 'Win32API::File Usage:  $OsFHandle= GetOsFHandle(FILE)';
    }
    my( $file )= @_;
    if(  ! ref($file)  ) {
	if(  $file !~ /('|::)/  ) {
	    $file= caller() . "::" . $file;
	}
	no strict "refs";
	# The eval "" is necessary in Perl 5.6, avoid it otherwise.
	my $tied = !defined($^]) || $^] &lt; 5.008
                       ? eval "tied *{$file}"
                       : tied *{$file};

	if (UNIVERSAL::isa($tied =&gt; __PACKAGE__)) {
		return $tied-&gt;win32_handle;
	}

	$file= *{$file};
    }
    my( $fd )= fileno($file);
    if(  ! defined( $fd )  ) {
	if(  $file =~ /^\d+\Z/  ) {
	    $fd= $file;
	} else {
	    return ();	# $! should be set by fileno().
	}
    }
    my $h= FdGetOsFHandle( $fd );
    if(  INVALID_HANDLE_VALUE() == $h  ) {
	$h= "";
    } elsif(  "0" eq $h  ) {
	$h= "0 but true";
    }
    return $h;
}

sub getFileSize {
    croak 'Win32API::File Usage:  $size= getFileSize($hNativeHandle)'
	if @_ != 1;

    my $handle    = shift;
    my $high_size = 0;

    my $low_size = GetFileSize($handle, $high_size);

    my $retval = $_64BITINT ? $high_size : Math::BigInt-&gt;new($high_size);

    $retval &lt;&lt;= $THIRTY_TWO;
    $retval +=  $low_size;

    return $retval;
}

sub setFilePointer {
    croak 'Win32API::File Usage:  $pos= setFilePointer($hNativeHandle, $posl, $from_where)'
	if @_ != 3;

    my ($handle, $pos, $from_where) = @_;

    my ($pos_low, $pos_high) = ($pos, 0);

    if ($_64BITINT) {
	$pos_low  = ($pos &amp; $FFFFFFFF);
	$pos_high = (($pos &gt;&gt; $THIRTY_TWO) &amp; $FFFFFFFF);
    }
    elsif (UNIVERSAL::isa($pos =&gt; 'Math::BigInt')) {
	$pos_low  = ($pos &amp; $FFFFFFFF)-&gt;numify();
	$pos_high = (($pos &gt;&gt; $THIRTY_TWO) &amp; $FFFFFFFF)-&gt;numify();
    }

    my $retval = SetFilePointer($handle, $pos_low, $pos_high, $from_where);

    if (defined $pos_high &amp;&amp; $pos_high != 0) {
	if (! $_64BITINT) {
	    $retval   = Math::BigInt-&gt;new($retval);
	    $pos_high = Math::BigInt-&gt;new($pos_high);
	}

	$retval += $pos_high &lt;&lt; $THIRTY_TWO;
    }

    return $retval;
}

sub attrLetsToBits
{
    my( $lets )= @_;
    my( %a )= (
      "a"=&gt;FILE_ATTRIBUTE_ARCHIVE(),	"c"=&gt;FILE_ATTRIBUTE_COMPRESSED(),
      "h"=&gt;FILE_ATTRIBUTE_HIDDEN(),	"o"=&gt;FILE_ATTRIBUTE_OFFLINE(),
      "r"=&gt;FILE_ATTRIBUTE_READONLY(),	"s"=&gt;FILE_ATTRIBUTE_SYSTEM(),
      "t"=&gt;FILE_ATTRIBUTE_TEMPORARY() );
    my( $bits )= 0;
    foreach(  split(//,$lets)  ) {
	croak "Win32API::File::attrLetsToBits: Unknown attribute letter ($_)"
	  unless  exists $a{$_};
	$bits |= $a{$_};
    }
    return $bits;
}

use vars qw( @_createFile_Opts %_createFile_Opts );
@_createFile_Opts= qw( Access Create Share Attributes
		       Flags Security Model );
@_createFile_Opts{@_createFile_Opts}= (1) x @_createFile_Opts;

sub createFile
{
    my $opts= "";
    if(  2 &lt;= @_  &amp;&amp;  "HASH" eq ref($_[$#_])  ) {
	$opts= pop( @_ );
    }
    my( $sPath, $svAccess, $svShare )= @_;
    if(  @_ &lt; 1  ||  3 &lt; @_  ) {
	croak "Win32API::File::createFile() usage:  \$hObject= createFile(\n",
	      "  \$sPath, [\$svAccess_qrw_ktn_ce,[\$svShare_rwd,]]",
	      " [{Option=&gt;\$Value}] )\n",
	      "    options: @_createFile_Opts\nCalled";
    }
    my( $create, $flags, $sec, $model )= ( "", 0, [], 0 );
    if(  ref($opts)  ) {
        my @err= grep( ! $_createFile_Opts{$_}, keys(%$opts) );
	@err  and  croak "_createFile:  Invalid options (@err)";
	$flags= $opts-&gt;{Flags}		if  exists( $opts-&gt;{Flags} );
	$flags |= attrLetsToBits( $opts-&gt;{Attributes} )
					if  exists( $opts-&gt;{Attributes} );
	$sec= $opts-&gt;{Security}		if  exists( $opts-&gt;{Security} );
	$model= $opts-&gt;{Model}		if  exists( $opts-&gt;{Model} );
	$svAccess= $opts-&gt;{Access}	if  exists( $opts-&gt;{Access} );
	$create= $opts-&gt;{Create}	if  exists( $opts-&gt;{Create} );
	$svShare= $opts-&gt;{Share}	if  exists( $opts-&gt;{Share} );
    }
    $svAccess= "r"		unless  defined($svAccess);
    $svShare= "rw"		unless  defined($svShare);
    if(  $svAccess =~ /^[qrw ktn ce]*$/i  ) {
	( my $c= $svAccess ) =~ tr/qrw QRW//d;
	$create= $c   if  "" ne $c  &amp;&amp;  "" eq $create;
	local( $_ )= $svAccess;
	$svAccess= 0;
	$svAccess |= GENERIC_READ()   if  /r/i;
	$svAccess |= GENERIC_WRITE()   if  /w/i;
    } elsif(  "?" eq $svAccess  ) {
	croak
	  "Win32API::File::createFile:  \$svAccess can use the following:\n",
	      "    One or more of the following:\n",
	      "\tq -- Query access (same as 0)\n",
	      "\tr -- Read access (GENERIC_READ)\n",
	      "\tw -- Write access (GENERIC_WRITE)\n",
	      "    At most one of the following:\n",
	      "\tk -- Keep if exists\n",
	      "\tt -- Truncate if exists\n",
	      "\tn -- New file only (fail if file already exists)\n",
	      "    At most one of the following:\n",
	      "\tc -- Create if doesn't exist\n",
	      "\te -- Existing file only (fail if doesn't exist)\n",
	      "  ''   is the same as 'q  k e'\n",
	      "  'r'  is the same as 'r  k e'\n",
	      "  'w'  is the same as 'w  t c'\n",
	      "  'rw' is the same as 'rw k c'\n",
	      "  'rt' or 'rn' implies 'c'.\n",
	      "  Or \$svAccess can be numeric.\n", "Called from";
    } elsif(  $svAccess == 0  &amp;&amp;  $svAccess !~ /^[-+.]*0/  ) {
	croak "Win32API::File::createFile:  Invalid \$svAccess ($svAccess)";
    }
    if(  $create =~ /^[ktn ce]*$/  ) {
        local( $_ )= $create;
        my( $k, $t, $n, $c, $e )= ( scalar(/k/i), scalar(/t/i),
	  scalar(/n/i), scalar(/c/i), scalar(/e/i) );
	if(  1 &lt; $k + $t + $n  ) {
	    croak "Win32API::File::createFile: \$create must not use ",
	      qq&lt;more than one of "k", "t", and "n" ($create)&gt;;
	}
	if(  $c  &amp;&amp;  $e  ) {
	    croak "Win32API::File::createFile: \$create must not use ",
	      qq&lt;both "c" and "e" ($create)&gt;;
	}
	my $r= ( $svAccess &amp; GENERIC_READ() ) == GENERIC_READ();
	my $w= ( $svAccess &amp; GENERIC_WRITE() ) == GENERIC_WRITE();
	if(  ! $k  &amp;&amp;  ! $t  &amp;&amp;  ! $n  ) {
	    if(  $w  &amp;&amp;  ! $r  ) {		$t= 1;
	    } else {				$k= 1; }
	}
	if(  $k  ) {
	    if(  $c  ||  $w &amp;&amp; ! $e  ) {	$create= OPEN_ALWAYS();
	    } else {				$create= OPEN_EXISTING(); }
	} elsif(  $t  ) {
	    if(  $e  ) {			$create= TRUNCATE_EXISTING();
	    } else {				$create= CREATE_ALWAYS(); }
	} else { # $n
	    if(  ! $e  ) {			$create= CREATE_NEW();
	    } else {
		croak "Win32API::File::createFile: \$create must not use ",
		  qq&lt;both "n" and "e" ($create)&gt;;
	    }
	}
    } elsif(  "?" eq $create  ) {
	croak 'Win32API::File::createFile: $create !~ /^[ktn ce]*$/;',
	      ' pass $svAccess as "?" for more information.';
    } elsif(  $create == 0  &amp;&amp;  $create ne "0"  ) {
	croak "Win32API::File::createFile: Invalid \$create ($create)";
    }
    if(  $svShare =~ /^[drw]*$/  ) {
        my %s= ( "d"=&gt;FILE_SHARE_DELETE(), "r"=&gt;FILE_SHARE_READ(),
	         "w"=&gt;FILE_SHARE_WRITE() );
        my @s= split(//,$svShare);
	$svShare= 0;
	foreach( @s ) {
	    $svShare |= $s{$_};
	}
    } elsif(  $svShare == 0  &amp;&amp;  $svShare !~ /^[-+.]*0/  ) {
	croak "Win32API::File::createFile: Invalid \$svShare ($svShare)";
    }
    return  CreateFileA(
	      $sPath, $svAccess, $svShare, $sec, $create, $flags, $model );
}


sub getLogicalDrives
{
    my( $ref )= @_;
    my $s= "";
    if(  ! GetLogicalDriveStringsA( 256, $s )  ) {
	return undef;
    }
    if(  ! defined($ref)  ) {
	return  split( /\0/, $s );
    } elsif(  "ARRAY" ne ref($ref)  ) {
	croak 'Usage:  C&lt;@arr= getLogicalDrives()&gt; ',
	      'or C&lt;getLogicalDrives(\\@arr)&gt;', "\n";
    }
    @$ref= split( /\0/, $s );
    return $ref;
}

###############################################################################
#   Experimental Tied Handle and Object Oriented interface.                   #
###############################################################################

sub new {
	my $class = shift;
	$class = ref $class || $class;

	my $self = IO::File::new($class);
	tie *$self, __PACKAGE__;

	$self-&gt;open(@_) if @_;

	return $self;
}

sub TIEHANDLE {
	my ($class, $win32_handle) = @_;
	$class = ref $class || $class;

	return bless {
		_win32_handle =&gt; $win32_handle,
		_binmode      =&gt; 0,
		_buffered     =&gt; 0,
		_buffer       =&gt; '',
		_eof          =&gt; 0,
		_fileno       =&gt; undef,
		_access       =&gt; 'r',
		_append       =&gt; 0,
	}, $class;
}

# This is called for getting the tied object from hard refs to glob refs in
# some cases, for reasons I don't quite grok.

sub FETCH { return $_[0] }

# Public accessors

sub win32_handle{ $_[0]-&gt;{_win32_handle}||= $_[1] }

# Protected accessors

sub _buffer	{ $_[0]-&gt;{_buffer}	||= $_[1] }
sub _binmode	{ $_[0]-&gt;{_binmode}	||= $_[1] }
sub _fileno	{ $_[0]-&gt;{_fileno}	||= $_[1] }
sub _access	{ $_[0]-&gt;{_access}	||= $_[1] }
sub _append	{ $_[0]-&gt;{_append}	||= $_[1] }

# Tie interface

sub OPEN {
	my $self  = shift;
	my $expr  = shift;
	croak "Only the two argument form of open is supported at this time" if @_;
# FIXME: this needs to parse the full Perl open syntax in $expr

	my ($mixed, $mode, $path) =
		($expr =~ /^\s* (\+)? \s* (&lt;|&gt;|&gt;&gt;)? \s* (.*?) \s*$/x);

	croak "Unsupported open mode" if not $path;

	my $access = 'r';
	my $append = $mode eq '&gt;&gt;' ? 1 : 0;

	if ($mixed) {
		$access = 'rw';
	} elsif($mode eq '&gt;') {
		$access = 'w';
	}

	my $w32_handle = createFile($path, $access);

	$self-&gt;win32_handle($w32_handle);

	$self-&gt;seek(1,2) if $append;

	$self-&gt;_access($access);
	$self-&gt;_append($append);

	return 1;
}

sub BINMODE {
	$_[0]-&gt;_binmode(1);
}

sub WRITE {
	my ($self, $buf, $len, $offset, $overlap) = @_;

	if ($offset) {
		$buf = substr($buf, $offset);
		$len = length($buf);
	}

	$len       = length($buf) if not defined $len;

	$overlap   = [] if not defined $overlap;;

	my $bytes_written = 0;

	WriteFile (
		$self-&gt;win32_handle, $buf, $len,
		$bytes_written, $overlap
	);

	return $bytes_written;
}

sub PRINT {
	my $self = shift;

	my $buf = join defined $, ? $, : "" =&gt; @_;

	$buf =~ s/\012/\015\012/sg unless $self-&gt;_binmode();

	$buf .= $\ if defined $\;

	$self-&gt;WRITE($buf, length($buf), 0);
}

sub READ {
	my $self = shift;
	my $into = \$_[0]; shift;
	my ($len, $offset, $overlap) = @_;

	my $buffer     = defined $self-&gt;_buffer ? $self-&gt;_buffer : "";
	my $buf_length = length($buffer);
	my $bytes_read = 0;
	my $data;
	$offset        = 0 if not defined $offset;

	if ($buf_length &gt;= $len) {
		$data       = substr($buffer, 0, $len =&gt; "");
		$bytes_read = $len;
		$self-&gt;_buffer($buffer);
	} else {
		if ($buf_length &gt; 0) {
			$len -= $buf_length;
			substr($$into, $offset) = $buffer;
			$offset += $buf_length;
		}

		$overlap ||= [];

		ReadFile (
			$self-&gt;win32_handle, $data, $len,
			$bytes_read, $overlap
		);
	}

	$$into = "" if not defined $$into;

	substr($$into, $offset) = $data;

	return $bytes_read;
}

sub READLINE {
	my $self = shift;
	my $line = "";

	while ((index $line, $/) == -1) { # read until end of line marker
		my $char = $self-&gt;GETC();

		last if !defined $char || $char eq '';

		$line .= $char;
	}

	return undef if $line eq '';

	return $line;
}


sub FILENO {
	my $self = shift;

	return $self-&gt;_fileno() if defined $self-&gt;_fileno();

	return -1 if $^O eq 'cygwin';

# FIXME: We don't always open the handle, better to query the handle or to set
# the right access info at TIEHANDLE time.

	my $access = $self-&gt;_access();
	my $mode   = $access eq 'rw' ? O_RDWR :
		$access eq 'w' ? O_WRONLY : O_RDONLY;

	$mode |= O_APPEND if $self-&gt;_append();

	$mode |= O_TEXT   if not $self-&gt;_binmode();

	return $self-&gt;_fileno ( OsfHandleOpenFd (
		$self-&gt;win32_handle, $mode
	));
}

sub SEEK {
	my ($self, $pos, $whence) = @_;

	$whence = 0 if not defined $whence;
	my @file_consts = map {
		fileConstant($_)
	} qw(FILE_BEGIN FILE_CURRENT FILE_END);

	my $from_where = $file_consts[$whence];

	return setFilePointer($self-&gt;win32_handle, $pos, $from_where);
}

sub TELL {
# SetFilePointer with position 0 at FILE_CURRENT will return position.
	return $_[0]-&gt;SEEK(0, 1);
}

sub EOF {
	my $self = shift;

	my $current = $self-&gt;TELL() + 0;
	my $end     = getFileSize($self-&gt;win32_handle) + 0;

	return $current == $end;
}

sub CLOSE {
	my $self = shift;

	my $retval = 1;
	
	if (defined $self-&gt;win32_handle) {
		$retval = CloseHandle($self-&gt;win32_handle);

		$self-&gt;win32_handle(undef);
	}

	return $retval;
}

# Only close the handle on explicit close, too many problems otherwise.
sub UNTIE {}

sub DESTROY {}

# End of Tie/OO Interface

# Autoload methods go after =cut, and are processed by the autosplit program.

1;
__END__

=head1 NAME

Win32API::File - Low-level access to Win32 system API calls for files/dirs.

=head1 SYNOPSIS

  use Win32API::File 0.08 qw( :ALL );

  MoveFile( $Source, $Destination )
    or  die "Can't move $Source to $Destination: ",fileLastError(),"\n";
  MoveFileEx( $Source, $Destination, MOVEFILE_REPLACE_EXISTING() )
    or  die "Can't move $Source to $Destination: ",fileLastError(),"\n";
  [...]

=head1 DESCRIPTION

This provides fairly low-level access to the Win32 System API
calls dealing with files and directories.

To pass in C&lt;NULL&gt; as the pointer to an optional buffer, pass in
an empty list reference, C&lt;[]&gt;.

Beyond raw access to the API calls and related constants, this module
handles smart buffer allocation and translation of return codes.

All functions, unless otherwise noted, return a true value for success
and a false value for failure and set C&lt;$^E&gt; on failure.

=head2 Object Oriented/Tied Handle Interface

WARNING: this is new code, use at your own risk.

This version of C&lt;Win32API::File&gt; can be used like an C&lt;IO::File&gt; object:

  my $file = Win32API::File-&gt;new("+&gt; foo");
  binmode $file;
  print $file "hello there\n";
  seek $file, 0, 0;
  my $line = &lt;$file&gt;;
  $file-&gt;close;

It also supports tying via a win32 handle (for example, from C&lt;createFile()&gt;):

  tie FILE, 'Win32API::File', $win32_handle;
  print FILE "...";

It has not been extensively tested yet and buffered I/O is not yet implemented.

=head2 Exports

Nothing is exported by default.  The following tags can be used to
have large sets of symbols exported:  C&lt;":Func"&gt;, C&lt;":FuncA"&gt;,
C&lt;":FuncW"&gt;, C&lt;":Misc"&gt;, C&lt;":DDD_"&gt;, C&lt;":DRIVE_"&gt;, C&lt;":FILE_"&gt;,
C&lt;":FILE_ATTRIBUTE_"&gt;, C&lt;":FILE_FLAG_"&gt;, C&lt;":FILE_SHARE_"&gt;,
C&lt;":FILE_TYPE_"&gt;, C&lt;":FS_"&gt;, C&lt;":FSCTL_"&gt;, C&lt;":HANDLE_FLAG_"&gt;,
C&lt;":IOCTL_STORAGE_"&gt;, C&lt;":IOCTL_DISK_"&gt;, C&lt;":GENERIC_"&gt;,
C&lt;":MEDIA_TYPE"&gt;, C&lt;":MOVEFILE_"&gt;, C&lt;":SECURITY_"&gt;, C&lt;":SEM_"&gt;,
and C&lt;":PARTITION_"&gt;.

=over

=item C&lt;":Func"&gt;

The basic function names:  C&lt;attrLetsToBits&gt;,         C&lt;createFile&gt;,
C&lt;fileConstant&gt;,           C&lt;fileLastError&gt;,          C&lt;getLogicalDrives&gt;,
C&lt;setFilePointer&gt;,         C&lt;getFileSize&gt;,
C&lt;CloseHandle&gt;,            C&lt;CopyFile&gt;,               C&lt;CreateFile&gt;,
C&lt;DefineDosDevice&gt;,        C&lt;DeleteFile&gt;,             C&lt;DeviceIoControl&gt;,
C&lt;FdGetOsFHandle&gt;,         C&lt;GetDriveType&gt;,           C&lt;GetFileAttributes&gt;,
C&lt;GetFileSize&gt;,            C&lt;GetFileType&gt;,            C&lt;GetHandleInformation&gt;,
C&lt;GetLogicalDrives&gt;,       C&lt;GetLogicalDriveStrings&gt;, C&lt;GetOsFHandle&gt;,
C&lt;GetOverlappedResult&gt;,    C&lt;GetVolumeInformation&gt;,   C&lt;IsContainerPartition&gt;,
C&lt;IsRecognizedPartition&gt;,  C&lt;MoveFile&gt;,               C&lt;MoveFileEx&gt;,
C&lt;OsFHandleOpen&gt;,          C&lt;OsFHandleOpenFd&gt;,        C&lt;QueryDosDevice&gt;,
C&lt;ReadFile&gt;,               C&lt;SetErrorMode&gt;,           C&lt;SetFilePointer&gt;,
C&lt;SetHandleInformation&gt;,   and C&lt;WriteFile&gt;.

=over

=item attrLetsToBits

=item C&lt;$uBits= attrLetsToBits( $sAttributeLetters )&gt;

Converts a string of file attribute letters into an unsigned value with
the corresponding bits set.  C&lt;$sAttributeLetters&gt; should contain zero
or more letters from C&lt;"achorst"&gt;:

=over

=item C&lt;"a"&gt;

C&lt;FILE_ATTRIBUTE_ARCHIVE&gt;

=item C&lt;"c"&gt;

C&lt;FILE_ATTRIBUTE_COMPRESSED&gt;

=item C&lt;"h"&gt;

C&lt;FILE_ATTRIBUTE_HIDDEN&gt;

=item C&lt;"o"&gt;

C&lt;FILE_ATTRIBUTE_OFFLINE&gt;

=item C&lt;"r"&gt;

C&lt;FILE_ATTRIBUTE_READONLY&gt;

=item C&lt;"s"&gt;

C&lt;FILE_ATTRIBUTE_SYSTEM&gt;

=item C&lt;"t"&gt;

C&lt;FILE_ATTRIBUTE_TEMPORARY&gt;

=back

=item createFile

=item C&lt;$hObject= createFile( $sPath )&gt;

=item C&lt;$hObject= createFile( $sPath, $rvhvOptions )&gt;

=item C&lt;$hObject= createFile( $sPath, $svAccess )&gt;

=item C&lt;$hObject= createFile( $sPath, $svAccess, $rvhvOptions )&gt;

=item C&lt;$hObject= createFile( $sPath, $svAccess, $svShare )&gt;

=item C&lt;$hObject= createFile( $sPath, $svAccess, $svShare, $rvhvOptions )&gt;

This is a Perl-friendly wrapper around C&lt;CreateFile&gt;.

On failure, C&lt;$hObject&gt; gets set to a false value and C&lt;regLastError()&gt;
and C&lt;$^E&gt; are set to the reason for the failure.  Otherwise,
C&lt;$hObject&gt; gets set to a Win32 native file handle which is always
a true value [returns C&lt;"0 but true"&gt; in the impossible(?) case of
the handle having a value of C&lt;0&gt;].

C&lt;$sPath&gt; is the path to the file [or device, etc.] to be opened.  See
C&lt;CreateFile&gt; for more information on possible special values for
C&lt;$sPath&gt;.  

C&lt;$svAccess&gt; can be a number containing the bit mask representing
the specific type(s) of access to the file that you desire.  See the
C&lt;$uAccess&gt; parameter to C&lt;CreateFile&gt; for more information on these
values.

More likely, C&lt;$svAccess&gt; is a string describing the generic type of
access you desire and possibly the file creation options to use.  In
this case, C&lt;$svAccess&gt; should contain zero or more characters from
C&lt;"qrw"&gt; [access desired], zero or one character each from C&lt;"ktn"&gt;
and C&lt;"ce"&gt;, and optional white space.  These letters stand for,
respectively, "Query access", "Read access", "Write access", "Keep if
exists", "Truncate if exists", "New file only", "Create if none", and
"Existing file only".  Case is ignored.

You can pass in C&lt;"?"&gt; for C&lt;$svAccess&gt; to have an error message
displayed summarizing its possible values.  This is very handy when
doing on-the-fly programming using the Perl debugger:

    Win32API::File::createFile:  $svAccess can use the following:
	One or more of the following:
	    q -- Query access (same as 0)
	    r -- Read access (GENERIC_READ)
	    w -- Write access (GENERIC_WRITE)
	At most one of the following:
	    k -- Keep if exists
	    t -- Truncate if exists
	    n -- New file only (fail if file already exists)
	At most one of the following:
	    c -- Create if doesn't exist
	    e -- Existing file only (fail if doesn't exist)
      ''   is the same as 'q  k e'
      'r'  is the same as 'r  k e'
      'w'  is the same as 'w  t c'
      'rw' is the same as 'rw k c'
      'rt' or 'rn' implies 'c'.
      Or $access can be numeric.

C&lt;$svAccess&gt; is designed to be "do what I mean", so you can skip
the rest of its explanation unless you are interested in the complex
details.  Note that, if you want write access to a device, you need
to specify C&lt;"k"&gt; [and perhaps C&lt;"e"&gt;, as in C&lt;"w ke"&gt; or C&lt;"rw ke"&gt;]
since Win32 suggests C&lt;OPEN_EXISTING&gt; be used when opening a device.

=over

=item C&lt;"q"&gt; 

Stands for "Query access".  This is really a no-op since you always have
query access when you open a file.  You can specify C&lt;"q"&gt; to document
that you plan to query the file [or device, etc.].  This is especially
helpful when you don't want read nor write access since something like
C&lt;"q"&gt; or C&lt;"q ke"&gt; may be easier to understand than just C&lt;""&gt; or C&lt;"ke"&gt;.

=item C&lt;"r"&gt;

Stands for "Read access".  Sets the C&lt;GENERIC_READ&gt; bit(s) in the
C&lt;$uAccess&gt; that is passed to C&lt;CreateFile&gt;.  This is the default
access if the C&lt;$svAccess&gt; parameter is missing [or if it is C&lt;undef&gt;
and C&lt;$rvhvOptions&gt; doesn't specify an C&lt;"Access"&gt; option].

=item C&lt;"w"&gt;

Stands for "Write access".  Sets the C&lt;GENERIC_WRITE&gt; bit(s) in the
C&lt;$uAccess&gt; that is passed to C&lt;CreateFile&gt;.

=item C&lt;"k"&gt;

Stands for "Keep if exists".  If the requested file exists, then it is
opened.  This is the default unless C&lt;GENERIC_WRITE&gt; access has been
requested but C&lt;GENERIC_READ&gt; access has not been requested.   Contrast
with C&lt;"t"&gt; and C&lt;"n"&gt;.

=item C&lt;"t"&gt;

Stands for "Truncate if exists".  If the requested file exists, then
it is truncated to zero length and then opened.  This is the default if
C&lt;GENERIC_WRITE&gt; access has been requested and C&lt;GENERIC_READ&gt; access
has not been requested.  Contrast with C&lt;"k"&gt; and C&lt;"n"&gt;.

=item C&lt;"n"&gt;

Stands for "New file only".  If the requested file exists, then it is
not opened and the C&lt;createFile&gt; call fails.  Contrast with C&lt;"k"&gt; and
C&lt;"t"&gt;.  Can't be used with C&lt;"e"&gt;.

=item C&lt;"c"&gt;

Stands for "Create if none".  If the requested file does not
exist, then it is created and then opened.  This is the default
if C&lt;GENERIC_WRITE&gt; access has been requested or if C&lt;"t"&gt; or
C&lt;"n"&gt; was specified.  Contrast with C&lt;"e"&gt;.

=item C&lt;"e"&gt;

Stands for "Existing file only".  If the requested file does not
exist, then nothing is opened and the C&lt;createFile&gt; call fails.  This
is the default unless C&lt;GENERIC_WRITE&gt; access has been requested or
C&lt;"t"&gt; or C&lt;"n"&gt; was specified.   Contrast with C&lt;"c"&gt;.   Can't be
used with C&lt;"n"&gt;.

=back

The characters from C&lt;"ktn"&gt; and C&lt;"ce"&gt; are combined to determine the
what value for C&lt;$uCreate&gt; to pass to C&lt;CreateFile&gt; [unless overridden
by C&lt;$rvhvOptions&gt;]:

=over

=item C&lt;"kc"&gt;

C&lt;OPEN_ALWAYS&gt;

=item C&lt;"ke"&gt;

C&lt;OPEN_EXISTING&gt;

=item C&lt;"tc"&gt;

C&lt;TRUNCATE_EXISTING&gt;

=item C&lt;"te"&gt;

C&lt;CREATE_ALWAYS&gt;

=item C&lt;"nc"&gt;

C&lt;CREATE_NEW&gt;

=item C&lt;"ne"&gt;

Illegal.

=back

C&lt;$svShare&gt; controls how the file is shared, that is, whether other
processes can have read, write, and/or delete access to the file while
we have it opened.  C&lt;$svShare&gt; will usually be a string containing zero
or more characters from C&lt;"rwd"&gt; but can also be a numeric bit mask.

C&lt;"r"&gt; sets the C&lt;FILE_SHARE_READ&gt; bit which allows other processes to have
read access to the file.  C&lt;"w"&gt; sets the C&lt;FILE_SHARE_WRITE&gt; bit which
allows other processes to have write access to the file.  C&lt;"d"&gt; sets the
C&lt;FILE_SHARE_DELETE&gt; bit which allows other processes to have delete access
to the file [ignored under Windows 95].

The default for C&lt;$svShare&gt; is C&lt;"rw"&gt; which provides the same sharing as
using regular perl C&lt;open()&gt;.

If another process currently has read, write, and/or delete access to
the file and you don't allow that level of sharing, then your call to
C&lt;createFile&gt; will fail.  If you requested read, write, and/or delete
access and another process already has the file open but doesn't allow
that level of sharing, then your call to C&lt;createFile&gt; will fail.  Once
you have the file open, if another process tries to open it with read,
write, and/or delete access and you don't allow that level of sharing,
then that process won't be allowed to open the file.

C&lt;$rvhvOptions&gt; is a reference to a hash where any keys must be from
the list C&lt;qw( Access Create Share Attributes Flags Security Model )&gt;.
The meaning of the value depends on the key name, as described below.
Any option values in C&lt;$rvhvOptions&gt; override the settings from
C&lt;$svAccess&gt; and C&lt;$svShare&gt; if they conflict.

=over

=item Flags =&gt; $uFlags

C&lt;$uFlags&gt; is an unsigned value having any of the C&lt;FILE_FLAG_*&gt; or
C&lt;FILE_ATTRIBUTE_*&gt; bits set.  Any C&lt;FILE_ATTRIBUTE_*&gt; bits set via the
C&lt;Attributes&gt; option are logically C&lt;or&gt;ed with these bits.  Defaults
to C&lt;0&gt;.

If opening the client side of a named pipe, then you can also specify
C&lt;SECURITY_SQOS_PRESENT&gt; along with one of the other C&lt;SECURITY_*&gt;
constants to specify the security quality of service to be used.

=item Attributes =&gt; $sAttributes

A string of zero or more characters from C&lt;"achorst"&gt; [see C&lt;attrLetsToBits&gt;
for more information] which are converted to C&lt;FILE_ATTRIBUTE_*&gt; bits to
be set in the C&lt;$uFlags&gt; argument passed to C&lt;CreateFile&gt;.

=item Security =&gt; $pSecurityAttributes

C&lt;$pSecurityAttributes&gt; should contain a C&lt;SECURITY_ATTRIBUTES&gt; structure
packed into a string or C&lt;[]&gt; [the default].

=item Model =&gt; $hModelFile

C&lt;$hModelFile&gt; should contain a handle opened with C&lt;GENERIC_READ&gt;
access to a model file from which file attributes and extended attributes
are to be copied.  Or C&lt;$hModelFile&gt; can be C&lt;0&gt; [the default].

=item Access =&gt; $sAccess

=item Access =&gt; $uAccess

C&lt;$sAccess&gt; should be a string of zero or more characters from
C&lt;"qrw"&gt; specifying the type of access desired:  "query" or C&lt;0&gt;,
"read" or C&lt;GENERIC_READ&gt; [the default], or "write" or
C&lt;GENERIC_WRITE&gt;.

C&lt;$uAccess&gt; should be an unsigned value containing bits set to
indicate the type of access desired.  C&lt;GENERIC_READ&gt; is the default.

=item Create =&gt; $sCreate

=item Create =&gt; $uCreate

C&lt;$sCreate&gt; should be a string containing zero or one character from
C&lt;"ktn"&gt; and zero or one character from C&lt;"ce"&gt;.  These stand for
"Keep if exists", "Truncate if exists", "New file only", "Create if
none", and "Existing file only".  These are translated into a
C&lt;$uCreate&gt; value.

C&lt;$uCreate&gt; should be one of C&lt;OPEN_ALWAYS&gt;, C&lt;OPEN_EXISTING&gt;,
C&lt;TRUNCATE_EXISTING&gt;, C&lt;CREATE_ALWAYS&gt;, or C&lt;CREATE_NEW&gt;.

=item Share =&gt; $sShare

=item Share =&gt; $uShare

C&lt;$sShare&gt; should be a string with zero or more characters from
C&lt;"rwd"&gt; that is translated into a C&lt;$uShare&gt; value.  C&lt;"rw"&gt; is
the default.

C&lt;$uShare&gt; should be an unsigned value having zero or more of the
following bits set:  C&lt;FILE_SHARE_READ&gt;, C&lt;FILE_SHARE_WRITE&gt;, and
C&lt;FILE_SHARE_DELETE&gt;.  C&lt;FILE_SHARE_READ|FILE_SHARE_WRITE&gt; is the
default.

=back

Examples:

    $hFlop= createFile( "//./A:", "r", "r" )
      or  die "Can't prevent others from writing to floppy: $^E\n";
    $hDisk= createFile( "//./C:", "rw ke", "" )
      or  die "Can't get exclusive access to C: $^E\n";
    $hDisk= createFile( $sFilePath, "ke",
      { Access=&gt;FILE_READ_ATTRIBUTES } )
      or  die "Can't read attributes of $sFilePath: $^E\n";
    $hTemp= createFile( "$ENV{Temp}/temp.$$", "wn", "",
      { Attributes=&gt;"hst", Flags=&gt;FILE_FLAG_DELETE_ON_CLOSE() } )
      or  die "Can't create temporary file, temp.$$: $^E\n";

=item getLogicalDrives

=item C&lt;@roots= getLogicalDrives()&gt;

Returns the paths to the root directories of all logical drives
currently defined.  This includes all types of drive letters, such
as floppies, CD-ROMs, hard disks, and network shares.  A typical
return value on a poorly equipped computer would be C&lt;("A:\\","C:\\")&gt;.

=item CloseHandle

=item C&lt;CloseHandle( $hObject )&gt;

Closes a Win32 native handle, such as one opened via C&lt;CreateFile&gt;. 
Like most routines, returns a true value if successful and a false
value [and sets C&lt;$^E&gt; and C&lt;regLastError()&gt;] on failure.

=item CopyFile

=item C&lt;CopyFile( $sOldFileName, $sNewFileName, $bFailIfExists )&gt;

C&lt;$sOldFileName&gt; is the path to the file to be copied. 
C&lt;$sNewFileName&gt; is the path to where the file should be copied. 
Note that you can B&lt;NOT&gt; just specify a path to a directory in
C&lt;$sNewFileName&gt; to copy the file to that directory using the
same file name.

If C&lt;$bFailIfExists&gt; is true and C&lt;$sNewFileName&gt; is the path to
a file that already exists, then C&lt;CopyFile&gt; will fail.  If
C&lt;$bFailIfExists&gt; is false, then the copy of the C&lt;$sOldFileNmae&gt;
file will overwrite the C&lt;$sNewFileName&gt; file if it already exists.

Like most routines, returns a true value if successful and a false
value [and sets C&lt;$^E&gt; and C&lt;regLastError()&gt;] on failure.

=item CreateFile

=item C&lt;$hObject= CreateFile( $sPath, $uAccess, $uShare, $pSecAttr, $uCreate, $uFlags, $hModel )&gt;

On failure, C&lt;$hObject&gt; gets set to a false value and C&lt;$^E&gt; and
C&lt;fileLastError()&gt; are set to the reason for the failure.  Otherwise,
C&lt;$hObject&gt; gets set to a Win32 native file handle which is always a
true value [returns C&lt;"0 but true"&gt; in the impossible(?) case of the
handle having a value of C&lt;0&gt;].

C&lt;$sPath&gt; is the path to the file [or device, etc.] to be opened.

C&lt;$sPath&gt; can use C&lt;"/"&gt; or C&lt;"\\"&gt; as path delimiters and can even
mix the two.  We will usually only use C&lt;"/"&gt; in our examples since
using C&lt;"\\"&gt; is usually harder to read.

Under Windows NT, C&lt;$sPath&gt; can start with C&lt;"//?/"&gt; to allow the use
of paths longer than C&lt;MAX_PATH&gt; [for UNC paths, replace the leading
C&lt;"//"&gt; with C&lt;"//?/UNC/"&gt;, as in C&lt;"//?/UNC/Server/Share/Dir/File.Ext"&gt;].

C&lt;$sPath&gt; can start with C&lt;"//./"&gt; to indicate that the rest of the
path is the name of a "DOS device."  You can use C&lt;QueryDosDevice&gt;
to list all current DOS devices and can add or delete them with
C&lt;DefineDosDevice&gt;.  If you get the source-code distribution of this
module from CPAN, then it includes an example script, F&lt;ex/ListDevs.plx&gt;
that will list all current DOS devices and their "native" definition.
Again, note that this doesn't work under Win95 nor Win98.

The most common such DOS devices include:

=over

=item C&lt;"//./PhysicalDrive0"&gt;

Your entire first hard disk.  Doesn't work under Windows 95.  This
allows you to read or write raw sectors of your hard disk and to use
C&lt;DeviceIoControl&gt; to perform miscellaneous queries and operations
to the hard disk.   Writing raw sectors and certain other operations
can seriously damage your files or the function of your computer.

Locking this for exclusive access [by specifying C&lt;0&gt; for C&lt;$uShare&gt;]
doesn't prevent access to the partitions on the disk nor their file
systems.  So other processes can still access any raw sectors within
a partition and can use the file system on the disk as usual.

=item C&lt;"//./C:"&gt;

Your F&lt;C:&gt; partition.  Doesn't work under Windows 95.  This allows
you to read or write raw sectors of that partition and to use
C&lt;DeviceIoControl&gt; to perform miscellaneous queries and operations
to the partition.  Writing raw sectors and certain other operations
can seriously damage your files or the function of your computer.

Locking this for exclusive access doesn't prevent access to the
physical drive that the partition is on so other processes can
still access the raw sectors that way.  Locking this for exclusive
access B&lt;does&gt; prevent other processes from opening the same raw
partition and B&lt;does&gt; prevent access to the file system on it.  It
even prevents the current process from accessing the file system
on that partition.

=item C&lt;"//./A:"&gt;

The raw floppy disk.  Doesn't work under Windows 95.  This allows
you to read or write raw sectors of the floppy disk and to use
C&lt;DeviceIoControl&gt; to perform miscellaneous queries and operations
to the floppy disk or drive.

Locking this for exclusive access prevents all access to the floppy.

=item C&lt;"//./PIPE/PipeName"&gt;

A named pipe, created via C&lt;CreateNamedPipe&gt;.

=back

C&lt;$uAccess&gt; is an unsigned value with bits set indicating the
type of access desired.  Usually either C&lt;0&gt; ["query" access],
C&lt;GENERIC_READ&gt;, C&lt;GENERIC_WRITE&gt;, C&lt;GENERIC_READ|GENERIC_WRITE&gt;,
or C&lt;GENERIC_ALL&gt;.  More specific types of access can be specified,
such as C&lt;FILE_APPEND_DATA&gt; or C&lt;FILE_READ_EA&gt;.

C&lt;$uShare&gt; controls how the file is shared, that is, whether other
processes can have read, write, and/or delete access to the file while
we have it opened.  C&lt;$uShare&gt; is an unsigned value with zero or more
of these bits set:  C&lt;FILE_SHARE_READ&gt;, C&lt;FILE_SHARE_WRITE&gt;, and
C&lt;FILE_SHARE_DELETE&gt;.

If another process currently has read, write, and/or delete access to
the file and you don't allow that level of sharing, then your call to
C&lt;CreateFile&gt; will fail.  If you requested read, write, and/or delete
access and another process already has the file open but doesn't allow
that level of sharing, then your call to C&lt;createFile&gt; will fail.  Once
you have the file open, if another process tries to open it with read,
write, and/or delete access and you don't allow that level of sharing,
then that process won't be allowed to open the file.

C&lt;$pSecAttr&gt; should either be C&lt;[]&gt; [for C&lt;NULL&gt;] or a
C&lt;SECURITY_ATTRIBUTES&gt; data structure packed into a string.
For example, if C&lt;$pSecDesc&gt; contains a C&lt;SECURITY_DESCRIPTOR&gt;
structure packed into a string, perhaps via:

    RegGetKeySecurity( $key, 4, $pSecDesc, 1024 );

then you can set C&lt;$pSecAttr&gt; via:

    $pSecAttr= pack( "L P i", 12, $pSecDesc, $bInheritHandle );

C&lt;$uCreate&gt; is one of the following values:  C&lt;OPEN_ALWAYS&gt;,
C&lt;OPEN_EXISTING&gt;, C&lt;TRUNCATE_EXISTING&gt;, C&lt;CREATE_ALWAYS&gt;, and
C&lt;CREATE_NEW&gt;.

C&lt;$uFlags&gt; is an unsigned value with zero or more bits set indicating
attributes to associate with the file [C&lt;FILE_ATTRIBUTE_*&gt; values] or
special options [C&lt;FILE_FLAG_*&gt; values].

If opening the client side of a named pipe, then you can also set
C&lt;$uFlags&gt; to include C&lt;SECURITY_SQOS_PRESENT&gt; along with one of the
other C&lt;SECURITY_*&gt; constants to specify the security quality of
service to be used.

C&lt;$hModel&gt; is C&lt;0&gt; [or C&lt;[]&gt;, both of which mean C&lt;NULL&gt;] or a Win32
native handle opened with C&lt;GENERIC_READ&gt; access to a model file from
which file attributes and extended attributes are to be copied if a
new file gets created.

Examples:

    $hFlop= CreateFile( "//./A:", GENERIC_READ(),
      FILE_SHARE_READ(), [], OPEN_EXISTING(), 0, [] )
      or  die "Can't prevent others from writing to floppy: $^E\n";
    $hDisk= CreateFile( $sFilePath, FILE_READ_ATTRIBUTES(),
      FILE_SHARE_READ()|FILE_SHARE_WRITE(), [], OPEN_EXISTING(), 0, [] )
      or  die "Can't read attributes of $sFilePath: $^E\n";
    $hTemp= CreateFile( "$ENV{Temp}/temp.$$", GENERIC_WRITE(), 0,
      CREATE_NEW(), FILE_FLAG_DELETE_ON_CLOSE()|attrLetsToBits("hst"), [] )
      or  die "Can't create temporary file, temp.$$: $^E\n";

=item DefineDosDevice

=item C&lt;DefineDosDevice( $uFlags, $sDosDeviceName, $sTargetPath )&gt;

Defines a new DOS device, overrides the current definition of a DOS
device, or deletes a definition of a DOS device.  Like most routines,
returns a true value if successful and a false value [and sets C&lt;$^E&gt;
and C&lt;regLastError()&gt;] on failure.

C&lt;$sDosDeviceName&gt; is the name of a DOS device for which we'd like
to add or delete a definition.

C&lt;$uFlags&gt; is an unsigned value with zero or more of the following
bits set:

=over

=item C&lt;DDD_RAW_TARGET_PATH&gt;

Indicates that C&lt;$sTargetPath&gt; will be a raw Windows NT object name. 
This usually means that C&lt;$sTargetPath&gt; starts with C&lt;"\\Device\\"&gt;. 
Note that you cannot use C&lt;"/"&gt; in place of C&lt;"\\"&gt; in raw target path
names.

=item C&lt;DDD_REMOVE_DEFINITION&gt;

Requests that a definition be deleted.  If C&lt;$sTargetPath&gt; is
C&lt;[]&gt; [for C&lt;NULL&gt;], then the most recently added definition for
C&lt;$sDosDeviceName&gt; is removed.  Otherwise the most recently added
definition matching C&lt;$sTargetPath&gt; is removed.

If the last definition is removed, then the DOS device name is
also deleted.

=item C&lt;DDD_EXACT_MATCH_ON_REMOVE&gt;

When deleting a definition, this bit causes each C&lt;$sTargetPath&gt; to
be compared to the full-length definition when searching for the most
recently added match.  If this bit is not set, then C&lt;$sTargetPath&gt;
only needs to match a prefix of the definition.

=back

C&lt;$sTargetPath&gt; is the DOS device's specific definition that you
wish to add or delete.  For C&lt;DDD_RAW_TARGET_PATH&gt;, these usually
start with C&lt;"\\Device\\"&gt;.  If the C&lt;DDD_RAW_TARGET_PATH&gt; bit is
not set, then C&lt;$sTargetPath&gt; is just an ordinary path to some file
or directory, providing the functionality of the B&lt;subst&gt; command.

=item DeleteFile

=item C&lt;DeleteFile( $sFileName )&gt;

Deletes the named file.  Compared to Perl's C&lt;unlink&gt;, C&lt;DeleteFile&gt;
has the advantage of not deleting read-only files.  For B&lt;some&gt;
versions of Perl, C&lt;unlink&gt; silently calls C&lt;chmod&gt; 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 C&lt;unlink&gt;.

Like most routines, returns a true value if successful and a false
value [and sets C&lt;$^E&gt; and C&lt;regLastError()&gt;] on failure.

=item DeviceIoControl

=item C&lt;DeviceIoControl( $hDevice, $uIoControlCode, $pInBuf, $lInBuf, $opOutBuf, $lOutBuf, $olRetBytes, $pOverlapped )&gt;

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 C&lt;$^E&gt; and
C&lt;regLastError()&gt;] on failure.

C&lt;$hDevice&gt; is a Win32 native file handle to a device [return value
from C&lt;CreateFile&gt;].

C&lt;$uIoControlCode&gt; is an unsigned value [a C&lt;IOCTL_*&gt; or C&lt;FSCTL_*&gt;
constant] indicating the type query or other operation to be performed.

C&lt;$pInBuf&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;] or a data structure packed into a
string.  The type of data structure depends on the C&lt;$uIoControlCode&gt;
value.  C&lt;$lInBuf&gt; is C&lt;0&gt; or the length of the structure in
C&lt;$pInBuf&gt;.  If C&lt;$pInBuf&gt; is not C&lt;[]&gt; and C&lt;$lInBuf&gt; is C&lt;0&gt;, then
C&lt;$lInBuf&gt; will automatically be set to C&lt;length($pInBuf)&gt; for you.

C&lt;$opOutBuf&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;] or will be set to contain a
returned data structure packed into a string.  C&lt;$lOutBuf&gt; indicates
how much space to allocate in C&lt;$opOutBuf&gt; for C&lt;DeviceIoControl&gt; to
store the data structure.  If C&lt;$lOutBuf&gt; is a number and C&lt;$opOutBuf&gt;
already has a buffer allocated for it that is larger than C&lt;$lOutBuf&gt;
bytes, then this larger buffer size will be passed to C&lt;DeviceIoControl&gt;.
However, you can force a specific buffer size to be passed to
C&lt;DeviceIoControl&gt; by prepending a C&lt;"="&gt; to the front of C&lt;$lOutBuf&gt;.

C&lt;$olRetBytes&gt; is C&lt;[]&gt; or is a scalar to receive the number of bytes
written to C&lt;$opOutBuf&gt;.  Even when C&lt;$olRetBytes&gt; is C&lt;[]&gt;, a valid
pointer to a C&lt;DWORD&gt; [and not C&lt;NULL&gt;] is passed to C&lt;DeviceIoControl&gt;.
In this case, C&lt;[]&gt; just means that you don't care about the value
that might be written to C&lt;$olRetBytes&gt;, which is usually the case
since you can usually use C&lt;length($opOutBuf)&gt; instead.

C&lt;$pOverlapped&gt; is C&lt;[]&gt; or is a C&lt;OVERLAPPED&gt; structure packed into
a string.  This is only useful if C&lt;$hDevice&gt; was opened with the
C&lt;FILE_FLAG_OVERLAPPED&gt; flag set.

=item FdGetOsFHandle

=item C&lt;$hNativeHandle= FdGetOsFHandle( $ivFd )&gt;

C&lt;FdGetOsFHandle&gt; simply calls C&lt;_get_osfhandle()&gt;.  It was renamed
to better fit in with the rest the function names of this module,
in particular to distinguish it from C&lt;GetOsFHandle&gt;.  It takes an
integer file descriptor [as from Perl's C&lt;fileno&gt;] and returns the
Win32 native file handle associated with that file descriptor or
C&lt;INVALID_HANDLE_VALUE&gt; if C&lt;$ivFd&gt; is not an open file descriptor.

When you call Perl's C&lt;open&gt; to set a Perl file handle [like C&lt;STDOUT&gt;],
Perl calls C's C&lt;fopen&gt; to set a stdio C&lt;FILE *&gt;.  C's C&lt;fopen&gt; calls
something like Unix's C&lt;open&gt;, that is, Win32's C&lt;_sopen&gt;, to get an
integer file descriptor [where 0 is for C&lt;STDIN&gt;, 1 for C&lt;STDOUT&gt;, etc.].
Win32's C&lt;_sopen&gt; calls C&lt;CreateFile&gt; to set a C&lt;HANDLE&gt;, a Win32 native
file handle.  So every Perl file handle [like C&lt;STDOUT&gt;] has an integer
file descriptor associated with it that you can get via C&lt;fileno&gt;.  And,
under Win32, every file descriptor has a Win32 native file handle
associated with it.  C&lt;FdGetOsFHandle&gt; lets you get access to that.

C&lt;$hNativeHandle&gt; is set to C&lt;INVALID_HANDLE_VALUE&gt; [and
C&lt;lastFileError()&gt; and C&lt;$^E&gt; are set] if C&lt;FdGetOsFHandle&gt; fails. 
See also C&lt;GetOsFHandle&gt; which provides a friendlier interface.

=item fileConstant

=item C&lt;$value= fileConstant( $sConstantName )&gt;

Fetch the value of a constant.  Returns C&lt;undef&gt; if C&lt;$sConstantName&gt;
is not the name of a constant supported by this module.  Never sets
C&lt;$!&gt; nor C&lt;$^E&gt;.

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 C&lt;use Win32API::File&gt; statement and then
simply using the constant name in your code [perhaps followed by
C&lt;()&gt;].  This function is useful for verifying constant names not in
Perl code, for example, after prompting a user to type in a constant
name.

=item fileLastError

=item C&lt;$svError= fileLastError();&gt;

=item C&lt;fileLastError( $uError );&gt;

Returns the last error encountered by a routine from this module. 
It is just like C&lt;$^E&gt; except it isn't changed by anything except
routines from this module.  Ideally you could just use C&lt;$^E&gt;, but
current versions of Perl often overwrite C&lt;$^E&gt; before you get a
chance to check it and really old versions of Perl don't really
support C&lt;$^E&gt; under Win32.

Just like C&lt;$^E&gt;, in a numeric context C&lt;fileLastError()&gt; 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 C&lt;$x= fileLastError()&gt; causes C&lt;$x&gt;
to give different values in string vs. numeric contexts].

The last form sets the error returned by future calls to
C&lt;fileLastError()&gt; and should not be used often.  C&lt;$uError&gt; must
be a numeric error code.  Also returns the dual-valued version
of C&lt;$uError&gt;.

=item GetDriveType

=item C&lt;$uDriveType= GetDriveType( $sRootPath )&gt;

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:

=over

=item C&lt;DRIVE_UNKNOWN&gt;

None of the following.

=item C&lt;DRIVE_NO_ROOT_DIR&gt;

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.

=item C&lt;DRIVE_REMOVABLE&gt;

A floppy diskette drive or other removable media drive, but not a CD-ROM
drive.

=item C&lt;DRIVE_FIXED&gt;

An ordinary hard disk partition.

=item C&lt;DRIVE_REMOTE&gt;

A network share.

=item C&lt;DRIVE_CDROM&gt;

A CD-ROM drive.

=item C&lt;DRIVE_RAMDISK&gt;

A "ram disk" or memory-resident virtual file system used for high-speed
access to small amounts of temporary file space.

=back

=item GetFileAttributes

=item C&lt;$uAttrs = GetFileAttributes( $sPath )&gt;

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:

=over

=item C&lt;FILE_ATTRIBUTE_ARCHIVE&gt;

The file or directory is an archive file or directory. Applications use
this attribute to mark files for backup or removal.

=item C&lt;FILE_ATTRIBUTE_COMPRESSED&gt;

The file or directory is compressed. For a file, this means that all of
the data in the file is compressed. For a directory, this means that
compression is the default for newly created files and subdirectories. 

=item C&lt;FILE_ATTRIBUTE_DEVICE&gt;

Reserved; do not use. 

=item C&lt;FILE_ATTRIBUTE_DIRECTORY&gt;

The handle identifies a directory. 

=item C&lt;FILE_ATTRIBUTE_ENCRYPTED&gt;

The file or directory is encrypted. For a file, this means that all data
streams in the file are encrypted. For a directory, this means that
encryption is the default for newly created files and subdirectories. 

=item C&lt;FILE_ATTRIBUTE_HIDDEN&gt;

The file or directory is hidden. It is not included in an ordinary directory
listing. 

=item C&lt;FILE_ATTRIBUTE_NORMAL&gt;

The file or directory has no other attributes set. This attribute is valid
only if used alone. 

=item C&lt;FILE_ATTRIBUTE_NOT_CONTENT_INDEXED&gt;

The file will not be indexed by the content indexing service. 

=item C&lt;FILE_ATTRIBUTE_OFFLINE&gt;

The data of the file is not immediately available. This attribute indicates
that the file data has been physically moved to offline storage. This
attribute is used by Remote Storage, the hierarchical storage management
software. Applications should not arbitrarily change this attribute. 

=item C&lt;FILE_ATTRIBUTE_READONLY&gt;

The file or directory is read-only. Applications can read the file but cannot
write to it or delete it. In the case of a directory, applications cannot
delete it. 

=item C&lt;FILE_ATTRIBUTE_REPARSE_POINT&gt;

The file or directory has an associated reparse point. 

=item C&lt;FILE_ATTRIBUTE_SPARSE_FILE&gt;

The file is a sparse file. 

=item C&lt;FILE_ATTRIBUTE_SYSTEM&gt;

The file or directory is part of, or is used exclusively by, the operating
system. 

=item C&lt;FILE_ATTRIBUTE_TEMPORARY&gt;

The file is being used for temporary storage. File systems avoid writing
data back to mass storage if sufficient cache memory is available, because
often the application deletes the temporary file shortly after the handle is
closed. In that case, the system can entirely avoid writing the data.
Otherwise, the data will be written after the handle is closed. 

=back

=item GetFileType

=item C&lt;$uFileType= GetFileType( $hFile )&gt;

Takes a Win32 native file handle and returns a C&lt;FILE_TYPE_*&gt; constant
indicating the type of the file opened on that handle:

=over

=item C&lt;FILE_TYPE_UNKNOWN&gt;

None of the below.  Often a special device.

=item C&lt;FILE_TYPE_DISK&gt;

An ordinary disk file.

=item C&lt;FILE_TYPE_CHAR&gt;

What Unix would call a "character special file", that is, a device that
works on character streams such as a printer port or a console.

=item C&lt;FILE_TYPE_PIPE&gt;

Either a named or anonymous pipe.

=back

=item getFileSize

=item C&lt;$size= getFileSize( $hFile )&gt;

This is a Perl-friendly wrapper for the C&lt;GetFileSize&gt; (below) API call.

It takes a Win32 native file handle and returns the size in bytes. Since the
size can be a 64 bit value, on non 64 bit integer Perls the value returned will
be an object of type C&lt;Math::BigInt&gt;.

=item GetFileSize

=item C&lt;$iSizeLow= GetFileSize($win32Handle, $iSizeHigh)&gt;

Returns the size of a file pointed to by C&lt;$win32Handle&gt;, optionally storing
the high order 32 bits into C&lt;$iSizeHigh&gt; if it is not C&lt;[]&gt;. If $iSizeHigh is
C&lt;[]&gt;, a non-zero value indicates success. Otherwise, on failure the return
value will be C&lt;0xffffffff&gt; and C&lt;fileLastError()&gt; will not be C&lt;NO_ERROR&gt;.

=item GetOverlappedResult

=item C&lt;$bRetval= GetOverlappedResult( $win32Handle, $pOverlapped,
 $numBytesTransferred, $bWait )&gt;

Used for asynchronous IO in Win32 to get the result of a pending IO operation,
such as when a file operation returns C&lt;ERROR_IO_PENDING&gt;. Returns a false
value on failure. The C&lt;$overlapped&gt; structure and C&lt;$numBytesTransferred&gt;
will be modified with the results of the operation.

As far as creating the C&lt;$pOverlapped&gt; structure, you are currently on your own.

See L&lt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getoverlappedresult.asp&gt; for more information.

=item GetLogicalDrives

=item C&lt;$uDriveBits= GetLogicalDrives()&gt;

Returns an unsigned value with one bit set for each drive letter currently
defined.  If "A:" is currently a valid drive letter, then the C&lt;1&gt; bit
will be set in C&lt;$uDriveBits&gt;.  If "B:" is valid, then the C&lt;2&gt; bit will
be set.  If "Z:" is valid, then the C&lt;2**26&gt; [C&lt;0x4000000&gt;] bit will be
set.

=item GetLogicalDriveStrings

=item C&lt;$olOutLength= GetLogicalDriveStrings( $lBufSize, $osBuffer )&gt;

For each currently defined drive letter, a C&lt;'\0'&gt;-terminated string
of the path to the root of its file system is constructed.  All of
these strings are concatenated into a single larger string and an
extra terminating C&lt;'\0'&gt; is added.  This larger string is returned
in C&lt;$osBuffer&gt;.  Note that this includes drive letters that have
been defined but that have no file system, such as drive letters
assigned to unformatted partitions.

C&lt;$lBufSize&gt; is the size of the buffer to allocate to store this
list of strings.  C&lt;26*4+1&gt; is always sufficient and should usually
be used.

C&lt;$osBuffer&gt; is a scalar to be set to contain the constructed string.

C&lt;$olOutLength&gt; is the number of bytes actually written to C&lt;$osBuffer&gt;
but C&lt;length($osBuffer)&gt; can also be used to determine this.

For example, on a poorly equipped computer,

    GetLogicalDriveStrings( 4*26+1, $osBuffer );

might set C&lt;$osBuffer&gt; to the 9-character string, C&lt;"A:\\\0C:\\\0\0"&gt;.

=item GetHandleInformation

=item C&lt;GetHandleInformation( $hObject, $ouFlags )&gt;

Retrieves the flags associated with a Win32 native file handle or object
handle.

C&lt;$hObject&gt; is an open Win32 native file handle or an open Win32 native
handle to some other type of object.

C&lt;$ouFlags&gt; will be set to an unsigned value having zero or more of
the bits C&lt;HANDLE_FLAG_INHERIT&gt; and C&lt;HANDLE_FLAG_PROTECT_FROM_CLOSE&gt;
set.  See the C&lt;":HANDLE_FLAG_"&gt; export class for the meanings of these
bits.

=item GetOsFHandle

=item C&lt;$hNativeHandle= GetOsFHandle( FILE )&gt;

Takes a Perl file handle [like C&lt;STDIN&gt;] and returns the Win32 native
file handle associated with it.  See C&lt;FdGetOsFHandle&gt; for more
information about Win32 native file handles.

C&lt;$hNativeHandle&gt; is set to a false value [and C&lt;lastFileError()&gt; and
C&lt;$^E&gt; are set] if C&lt;GetOsFHandle&gt; fails.    C&lt;GetOsFHandle&gt; returns
C&lt;"0 but true"&gt; in the impossible(?) case of the handle having a value
of C&lt;0&gt;.

=item GetVolumeInformation

=item C&lt;GetVolumeInformation( $sRootPath, $osVolName, $lVolName, $ouSerialNum, $ouMaxNameLen, $ouFsFlags, $osFsType, $lFsType )&gt;

Gets information about a file system volume, returning a true
value if successful.  On failure, returns a false value and sets
C&lt;fileLastError()&gt; and C&lt;$^E&gt;.

C&lt;$sRootPath&gt; is a string specifying the path to the root of the file system,
for example, C&lt;"C:/"&gt;.

C&lt;$osVolName&gt; is a scalar to be set to the string representing the
volume name, also called the file system label.  C&lt;$lVolName&gt; is the
number of bytes to allocate for the C&lt;$osVolName&gt; buffer [see
L&lt;Buffer Sizes&gt; for more information].

C&lt;$ouSerialNum&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;] or will be set to the numeric
value of the volume's serial number.

C&lt;$ouMaxNameLen&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;] or will be set to the maximum
length allowed for a file name or directory name within the file system.

C&lt;$osFsType&gt; is a scalar to be set to the string representing the
file system type, such as C&lt;"FAT"&gt; or C&lt;"NTFS"&gt;.  C&lt;$lFsType&gt; is the
number of bytes to allocate for the C&lt;$osFsType&gt; buffer [see
L&lt;Buffer Sizes&gt; for more information].

C&lt;$ouFsFlags&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;] or will be set to an unsigned integer
with bits set indicating properties of the file system:

=over

=item C&lt;FS_CASE_IS_PRESERVED&gt;

The file system preserves the case of file names [usually true].
That is, it doesn't change the case of file names such as forcing
them to upper- or lower-case.

=item C&lt;FS_CASE_SENSITIVE&gt;

The file system supports the ability to not ignore the case of file
names [but might ignore case the way you are using it].  That is, the
file system has the ability to force you to get the letter case of a
file's name exactly right to be able to open it.  This is true for
"NTFS" file systems, even though case in file names is usually still
ignored.

=item C&lt;FS_UNICODE_STORED_ON_DISK&gt;

The file system preserves Unicode in file names [true for "NTFS"].

=item C&lt;FS_PERSISTENT_ACLS&gt;

The file system supports setting Access Control Lists on files [true
for "NTFS"].

=item C&lt;FS_FILE_COMPRESSION&gt;

The file system supports compression on a per-file basis [true for
"NTFS"].

=item C&lt;FS_VOL_IS_COMPRESSED&gt;

The entire file system is compressed such as via "DoubleSpace".

=back

=item IsRecognizedPartition

=item C&lt;IsRecognizedPartition( $ivPartitionType )&gt;

Takes a partition type and returns whether that partition type is
supported under Win32.  C&lt;$ivPartitonType&gt; is an integer value as from
the operating system byte of a hard disk's DOS-compatible partition
table [that is, a partition table for x86-based Win32, not, for
example, one used with Windows NT for Alpha processors].  For example,
the C&lt;PartitionType&gt; member of the C&lt;PARTITION_INFORMATION&gt; structure.

Common values for C&lt;$ivPartitionType&gt; include C&lt;PARTITION_FAT_12==1&gt;,
C&lt;PARTITION_FAT_16==4&gt;, C&lt;PARTITION_EXTENDED==5&gt;, C&lt;PARTITION_FAT32==0xB&gt;.

=item IsContainerPartition

=item C&lt;IsContainerPartition( $ivPartitionType )&gt;

Takes a partition type and returns whether that partition is a
"container" partition that is supported under Win32, that is, whether
it is an "extended" partition that can contain "logical" partitions. 
C&lt;$ivPartitonType&gt; is as for C&lt;IsRecognizedPartition&gt;.

=item MoveFile

=item C&lt;MoveFile( $sOldName, $sNewName )&gt;

Renames a file or directory.  C&lt;$sOldName&gt; is the name of the existing
file or directory that is to be renamed.  C&lt;$sNewName&gt; is the new name
to give the file or directory.  Returns a true value if the move
succeeds.  For failure, returns a false value and sets
C&lt;fileLastErorr()&gt; and C&lt;$^E&gt; to the reason for the failure.

Files can be "renamed" between file systems and the file contents and
some attributes will be moved.  Directories can only be renamed within
one file system.  If there is already a file or directory named
C&lt;$sNewName&gt;, then C&lt;MoveFile&gt; will fail.

=item MoveFileEx

=item C&lt;MoveFileEx( $sOldName, $sNewName, $uFlags )&gt;

Renames a file or directory.  C&lt;$sOldName&gt; is the name of the existing
file or directory that is to be renamed.  C&lt;$sNewName&gt; is the new name
to give the file or directory.  Returns a true value if the move
succeeds.  For failure, returns a false value and sets
C&lt;fileLastErorr()&gt; and C&lt;$^E&gt; to the reason for the failure.

C&lt;$uFlags&gt; is an unsigned value with zero or more of the following bits set:

=over

=item C&lt;MOVEFILE_REPLACE_EXISTING&gt;

If this bit is set and a file [but not a directory] named C&lt;$sNewName&gt;
already exists, then it will be replaced by C&lt;$sOldName&gt;.  If this bit
is not set then C&lt;MoveFileEx&gt; will fail rather than replace an existing
C&lt;$sNewName&gt;.

=item C&lt;MOVEFILE_COPY_ALLOWED&gt;

Allows files [but not directories] to be moved between file systems
by copying the C&lt;$sOldName&gt; file data and some attributes to
C&lt;$sNewName&gt; and then deleting C&lt;$sOldName&gt;.  If this bit is not set
[or if C&lt;$sOldName&gt; denotes a directory] and C&lt;$sNewName&gt; refers to a
different file system than C&lt;$sOldName&gt;, then C&lt;MoveFileEx&gt; will fail.

=item C&lt;MOVEFILE_DELAY_UNTIL_REBOOT&gt;

Preliminary verifications are made and then an entry is added to the
Registry to cause the rename [or delete] operation to be done the
next time this copy of the operating system is booted [right after
any automatic file system checks have completed].  This is not
supported under Windows 95.

When this bit is set, C&lt;$sNewName&gt; can be C&lt;[]&gt; [for C&lt;NULL&gt;] to
indicate that C&lt;$sOldName&gt; should be deleted during the next boot
rather than renamed.

Setting both the C&lt;MOVEFILE_COPY_ALLOWED&gt; and
C&lt;MOVEFILE_DELAY_UNTIL_REBOOT&gt; bits will cause C&lt;MoveFileEx&gt; to fail.

=item C&lt;MOVEFILE_WRITE_THROUGH&gt;

Ensures that C&lt;MoveFileEx&gt; won't return until the operation has
finished and been flushed to disk.   This is not supported under
Windows 95.  Only affects file renames to another file system,
forcing a buffer flush at the end of the copy operation.

=back

=item OsFHandleOpen

=item C&lt;OsFHandleOpen( FILE, $hNativeHandle, $sMode )&gt;

Opens a Perl file handle based on an already open Win32 native
file handle [much like C's C&lt;fdopen()&gt; does with a file descriptor].
Returns a true value if the open operation succeeded.  For failure,
returns a false value and sets C&lt;$!&gt; [and possibly C&lt;fileLastError()&gt;
and C&lt;$^E&gt;] to the reason for the failure.

C&lt;FILE&gt; is a Perl file handle [in any of the supported forms, a
bareword, a string, a typeglob, or a reference to a typeglob] that
will be opened.  If C&lt;FILE&gt; is already open, it will automatically
be closed before it is reopened.

C&lt;$hNativeHandle&gt; is an open Win32 native file handle, probably the
return value from C&lt;CreateFile&gt; or C&lt;createFile&gt;.

C&lt;$sMode&gt; is string of zero or more letters from C&lt;"rwatb"&gt;.  These
are translated into a combination C&lt;O_RDONLY&gt; [C&lt;"r"&gt;], C&lt;O_WRONLY&gt;
[C&lt;"w"&gt;], C&lt;O_RDWR&gt; [C&lt;"rw"&gt;], C&lt;O_APPEND&gt; [C&lt;"a"&gt;], C&lt;O_TEXT&gt;
[C&lt;"t"&gt;], and C&lt;O_BINARY&gt; [C&lt;"b"&gt;] flags [see the L&lt;Fcntl&gt; module]
that is passed to C&lt;OsFHandleOpenFd&gt;.   Currently only C&lt;O_APPEND&gt;
and C&lt;O_TEXT&gt; have any significance.

Also, a C&lt;"r"&gt; and/or C&lt;"w"&gt; in C&lt;$sMode&gt; is used to decide how the
file descriptor is converted into a Perl file handle, even though this
doesn't appear to make a difference.  One of the following is used:

    open( FILE, "&lt;&amp;=".$ivFd )	# "r" w/o "w"
    open( FILE, "&gt;&amp;=".$ivFd )	# "w" w/o "r"
    open( FILE, "+&lt;&amp;=".$ivFd )	# both "r" and "w"

C&lt;OsFHandleOpen&gt; eventually calls the Win32-specific C routine
C&lt;_open_osfhandle()&gt; or Perl's "improved" version called
C&lt;win32_open_osfhandle()&gt;.  Prior to Perl5.005, C's
C&lt;_open_osfhandle()&gt; is called which will fail if
C&lt;GetFileType($hNativeHandle)&gt; would return C&lt;FILE_TYPE_UNKNOWN&gt;.  For
Perl5.005 and later, C&lt;OsFHandleOpen&gt; calls C&lt;win32_open_osfhandle()&gt;
from the Perl DLL which doesn't have this restriction.

=item OsFHandleOpenFd

=item C&lt;$ivFD= OsFHandleOpenFd( $hNativeHandle, $uMode )&gt;

Opens a file descriptor [C&lt;$ivFD&gt;] based on an already open Win32
native file handle, C&lt;$hNativeHandle&gt;.  This just calls the
Win32-specific C routine C&lt;_open_osfhandle()&gt; or Perl's "improved"
version called C&lt;win32_open_osfhandle()&gt;.  Prior to Perl5.005 and in Cygwin
Perl, C's C&lt;_open_osfhandle()&gt; is called which will fail if
C&lt;GetFileType($hNativeHandle)&gt; would return C&lt;FILE_TYPE_UNKNOWN&gt;.  For
Perl5.005 and later, C&lt;OsFHandleOpenFd&gt; calls C&lt;win32_open_osfhandle()&gt; from
the Perl DLL which doesn't have this restriction.

C&lt;$uMode&gt; the logical combination of zero or more C&lt;O_*&gt; constants
exported by the C&lt;Fcntl&gt; module.  Currently only C&lt;O_APPEND&gt; and
C&lt;O_TEXT&gt; have any significance.

C&lt;$ivFD&gt; will be non-negative if the open operation was successful. 
For failure, C&lt;-1&gt; is returned and C&lt;$!&gt; [and possibly
C&lt;fileLastError()&gt; and C&lt;$^E&gt;] is set to the reason for the failure.

=item QueryDosDevice

=item C&lt;$olTargetLen= QueryDosDevice( $sDosDeviceName, $osTargetPath, $lTargetBuf )&gt;

Looks up the definition of a given "DOS" device name, yielding the
active Windows NT native device name along with any currently dormant
definitions.

C&lt;$sDosDeviceName&gt; is the name of the "DOS" device whose definitions
we want.  For example, C&lt;"C:"&gt;, C&lt;"COM1"&gt;, or C&lt;"PhysicalDrive0"&gt;.
If C&lt;$sDosDeviceName&gt; is C&lt;[]&gt; [for C&lt;NULL&gt;], the list of all DOS
device names is returned instead.

C&lt;$osTargetPath&gt; will be assigned a string containing the list of
definitions.  The definitions are each C&lt;'\0'&gt;-terminate and are
concatenated into the string, most recent first, with an extra C&lt;'\0'&gt;
at the end of the whole string [see C&lt;GetLogicalDriveStrings&gt; for
a sample of this format].

C&lt;$lTargetBuf&gt; is the size [in bytes] of the buffer to allocate for
C&lt;$osTargetPath&gt;.  See L&lt;Buffer Sizes&gt; for more information.

C&lt;$olTargetLen&gt; is set to the number of bytes written to
C&lt;$osTargetPath&gt; but you can also use C&lt;length($osTargetPath)&gt;
to determine this.

For failure, C&lt;0&gt; is returned and C&lt;fileLastError()&gt; and C&lt;$^E&gt; are
set to the reason for the failure.

=item ReadFile

=item C&lt;ReadFile( $hFile, $opBuffer, $lBytes, $olBytesRead, $pOverlapped )&gt;

Reads bytes from a file or file-like device.  Returns a true value if
the read operation was successful.  For failure, returns a false value
and sets C&lt;fileLastError()&gt; and C&lt;$^E&gt; for the reason for the failure.

C&lt;$hFile&gt; is a Win32 native file handle that is already open to the
file or device to read from.

C&lt;$opBuffer&gt; will be set to a string containing the bytes read.

C&lt;$lBytes&gt; is the number of bytes you would like to read. 
C&lt;$opBuffer&gt; is automatically initialized to have a buffer large
enough to hold that many bytes.  Unlike other buffer sizes, C&lt;$lBytes&gt;
does not need to have a C&lt;"="&gt; prepended to it to prevent a larger
value to be passed to the underlying Win32 C&lt;ReadFile&gt; API.  However,
a leading C&lt;"="&gt; will be silently ignored, even if Perl warnings are
enabled.

If C&lt;$olBytesRead&gt; is not C&lt;[]&gt;, it will be set to the actual number
of bytes read, though C&lt;length($opBuffer)&gt; can also be used to
determine this.

C&lt;$pOverlapped&gt; is C&lt;[]&gt; or is a C&lt;OVERLAPPED&gt; structure packed
into a string.  This is only useful if C&lt;$hFile&gt; was opened with
the C&lt;FILE_FLAG_OVERLAPPED&gt; flag set.

=item SetErrorMode

=item C&lt;$uOldMode= SetErrorMode( $uNewMode )&gt;

Sets the mode controlling system error handling B&lt;and&gt; returns the
previous mode value.  Both C&lt;$uOldMode&gt; and C&lt;$uNewMode&gt; will have
zero or more of the following bits set:

=over

=item C&lt;SEM_FAILCRITICALERRORS&gt;

If set, indicates that when a critical error is encountered, the call
that triggered the error fails immediately.  Normally this bit is not
set, which means that a critical error causes a dialogue box to appear
notifying the desktop user that some application has triggered a
critical error.   The dialogue box allows the desktop user to decide
whether the critical error is returned to the process, is ignored, or
the offending operation is retried.

This affects the C&lt;CreateFile&gt; and C&lt;GetVolumeInformation&gt; calls.

Setting this bit is useful for allowing you to check whether a floppy
diskette is in the floppy drive.

=item C&lt;SEM_NOALIGNMENTFAULTEXCEPT&gt;

If set, this causes memory access misalignment faults to be
automatically fixed in a manner invisible to the process.  This flag
is ignored on x86-based versions of Windows NT.  This flag is not
supported on Windows 95.

=item C&lt;SEM_NOGPFAULTERRORBOX&gt;

If set, general protection faults do not generate a dialogue box but
can instead be handled by the process via an exception handler.  This
bit should not be set by programs that don't know how to handle such
faults.

=item C&lt;SEM_NOOPENFILEERRORBOX&gt;

If set, then when an attempt to continue reading from or writing to
an already open file [usually on a removable medium like a floppy
diskette] finds the file no longer available, the call will
immediately fail.  Normally this bit is not set, which means that
instead a dialogue box will appear notifying the desktop user that
some application has run into this problem.   The dialogue box allows
the desktop user to decide whether the failure is returned to the
process, is ignored, or the offending operation is retried.

This affects the C&lt;ReadFile&gt; and C&lt;WriteFile&gt; calls.

=back

=item setFilePointer

=item C&lt;$uNewPos = setFilePointer( $hFile, $ivOffset, $uFromWhere )&gt;

This is a perl-friendly wrapper for the SetFilePointer API (below).
C&lt;$ivOffset&gt; can be a 64 bit integer or C&lt;Math::BigInt&gt; object if your Perl
doesn't have 64 bit integers. The return value is the new offset and will
likewise be a 64 bit integer or a C&lt;Math::BigInt&gt; object.

=item SetFilePointer

=item C&lt;$uNewPos = SetFilePointer( $hFile, $ivOffset, $ioivOffsetHigh, $uFromWhere )&gt;

The native Win32 version of C&lt;seek()&gt;.  C&lt;SetFilePointer&gt; sets the
position within a file where the next read or write operation will
start from.

C&lt;$hFile&gt; is a Win32 native file handle.

C&lt;$uFromWhere&gt; is either C&lt;FILE_BEGIN&gt;, C&lt;FILE_CURRENT&gt;, or
C&lt;FILE_END&gt;, indicating that the new file position is being specified
relative to the beginning of the file, the current file pointer, or
the end of the file, respectively.

C&lt;$ivOffset&gt; is [if C&lt;$ioivOffsetHigh&gt; is C&lt;[]&gt;] the offset [in bytes]
to the new file position from the position specified via
C&lt;$uFromWhere&gt;.  If C&lt;$ioivOffsetHigh&gt; is not C&lt;[]&gt;, then C&lt;$ivOffset&gt;
is converted to an unsigned value to be used as the low-order 4 bytes
of the offset.

C&lt;$ioivOffsetHigh&gt; can be C&lt;[]&gt; [for C&lt;NULL&gt;] to indicate that you are
only specifying a 4-byte offset and the resulting file position will
be 0xFFFFFFFE or less [just under 4GB].  Otherwise C&lt;$ioivOfffsetHigh&gt;
starts out with the high-order 4 bytes [signed] of the offset and gets
set to the [unsigned] high-order 4 bytes of the resulting file position.

The underlying C&lt;SetFilePointer&gt; returns C&lt;0xFFFFFFFF&gt; to indicate
failure, but if C&lt;$ioivOffsetHigh&gt; is not C&lt;[]&gt;, you would also have
to check C&lt;$^E&gt; to determine whether C&lt;0xFFFFFFFF&gt; indicates an error
or not.  C&lt;Win32API::File::SetFilePointer&gt; does this checking for you
and returns a false value if and only if the underlying
C&lt;SetFilePointer&gt; failed.  For this reason, C&lt;$uNewPos&gt; is set to
C&lt;"0 but true"&gt; if you set the file pointer to the beginning of the
file [or any position with 0 for the low-order 4 bytes].

So the return value will be true if the seek operation was successful.
For failure, a false value is returned and C&lt;fileLastError()&gt; and
C&lt;$^E&gt; are set to the reason for the failure.

=item SetHandleInformation

=item C&lt;SetHandleInformation( $hObject, $uMask, $uFlags )&gt;

Sets the flags associated with a Win32 native file handle or object
handle.  Returns a true value if the operation was successful.  For
failure, returns a false value and sets C&lt;fileLastError()&gt; and C&lt;$^E&gt;
for the reason for the failure.

C&lt;$hObject&gt; is an open Win32 native file handle or an open Win32 native
handle to some other type of object.

C&lt;$uMask&gt; is an unsigned value having one or more of the bits
C&lt;HANDLE_FLAG_INHERIT&gt; and C&lt;HANDLE_FLAG_PROTECT_FROM_CLOSE&gt; set.
Only bits set in C&lt;$uMask&gt; will be modified by C&lt;SetHandleInformation&gt;.

C&lt;$uFlags&gt; is an unsigned value having zero or more of the bits
C&lt;HANDLE_FLAG_INHERIT&gt; and C&lt;HANDLE_FLAG_PROTECT_FROM_CLOSE&gt; set.
For each bit set in C&lt;$uMask&gt;, the corresponding bit in the handle's
flags is set to the value of the corresponding bit in C&lt;$uFlags&gt;.

If C&lt;$uOldFlags&gt; were the value of the handle's flags before the
call to C&lt;SetHandleInformation&gt;, then the value of the handle's
flags afterward would be:

    ( $uOldFlags &amp; ~$uMask ) | ( $uFlags &amp; $uMask )

[at least as far as the C&lt;HANDLE_FLAG_INHERIT&gt; and
C&lt;HANDLE_FLAG_PROTECT_FROM_CLOSE&gt; bits are concerned.]

See the C&lt;":HANDLE_FLAG_"&gt; export class for the meanings of these bits.

=item WriteFile

=item C&lt;WriteFile( $hFile, $pBuffer, $lBytes, $ouBytesWritten, $pOverlapped )&gt;

Write bytes to a file or file-like device.  Returns a true value if
the operation was successful.  For failure, returns a false value and
sets C&lt;fileLastError()&gt; and C&lt;$^E&gt; for the reason for the failure.

C&lt;$hFile&gt; is a Win32 native file handle that is already open to the
file or device to be written to.

C&lt;$pBuffer&gt; is a string containing the bytes to be written.

C&lt;$lBytes&gt; is the number of bytes you would like to write.  If
C&lt;$pBuffer&gt; is not at least C&lt;$lBytes&gt; long, C&lt;WriteFile&gt; croaks.  You
can specify C&lt;0&gt; for C&lt;$lBytes&gt; to write C&lt;length($pBuffer)&gt; bytes.
A leading C&lt;"="&gt; on C&lt;$lBytes&gt; will be silently ignored, even if Perl
warnings are enabled.

C&lt;$ouBytesWritten&gt; will be set to the actual number of bytes written
unless you specify it as C&lt;[]&gt;.

C&lt;$pOverlapped&gt; is C&lt;[]&gt; or is an C&lt;OVERLAPPED&gt; structure packed
into a string.  This is only useful if C&lt;$hFile&gt; was opened with
the C&lt;FILE_FLAG_OVERLAPPED&gt; flag set.

=back

=item C&lt;":FuncA"&gt;

The ASCII-specific functions.  Each of these is just the same as the
version without the trailing "A".

	CopyFileA
	CreateFileA
	DefineDosDeviceA
	DeleteFileA
	GetDriveTypeA
	GetFileAttributesA
	GetLogicalDriveStringsA
	GetVolumeInformationA
	MoveFileA
	MoveFileExA
	QueryDosDeviceA

=item C&lt;":FuncW"&gt;

The wide-character-specific (Unicode) functions.  Each of these is
just the same as the version without the trailing "W" except that
strings are expected in Unicode and some lengths are measured as
number of C&lt;WCHAR&gt;s instead of number of bytes, as indicated below.

=over

=item CopyFileW

=item C&lt;CopyFileW( $swOldFileName, $swNewFileName, $bFailIfExists )&gt;

C&lt;$swOldFileName&gt; and C&lt;$swNewFileName&gt; are Unicode strings.

=item CreateFileW

=item C&lt;$hObject= CreateFileW( $swPath, $uAccess, $uShare, $pSecAttr, $uCreate, $uFlags, $hModel )&gt;

C&lt;$swPath&gt; is Unicode.

=item DefineDosDeviceW

=item C&lt;DefineDosDeviceW( $uFlags, $swDosDeviceName, $swTargetPath )&gt;

C&lt;$swDosDeviceName&gt; and C&lt;$swTargetPath&gt; are Unicode.

=item DeleteFileW

=item C&lt;DeleteFileW( $swFileName )&gt;

C&lt;$swFileName&gt; is Unicode.

=item GetDriveTypeW

=item C&lt;$uDriveType= GetDriveTypeW( $swRootPath )&gt;

C&lt;$swRootPath&gt; is Unicode.

=item GetFileAttributesW

=item C&lt;$uAttrs= GetFileAttributesW( $swPath )&gt;

C&lt;$swPath&gt; is Unicode.

=item GetLogicalDriveStringsW

=item C&lt;$olwOutLength= GetLogicalDriveStringsW( $lwBufSize, $oswBuffer )&gt;

Unicode is stored in C&lt;$oswBuffer&gt;.  C&lt;$lwBufSize&gt; and C&lt;$olwOutLength&gt;
are measured as number of C&lt;WCHAR&gt;s.

=item GetVolumeInformationW

=item C&lt;GetVolumeInformationW( $swRootPath, $oswVolName, $lwVolName, $ouSerialNum, $ouMaxNameLen, $ouFsFlags, $oswFsType, $lwFsType )&gt;

C&lt;$swRootPath&gt; is Unicode and Unicode is written to C&lt;$oswVolName&gt; and
C&lt;$oswFsType&gt;.  C&lt;$lwVolName&gt; and C&lt;$lwFsType&gt; are measures as number
of C&lt;WCHAR&gt;s.

=item MoveFileW

=item C&lt;MoveFileW( $swOldName, $swNewName )&gt;

C&lt;$swOldName&gt; and C&lt;$swNewName&gt; are Unicode.

=item MoveFileExW

=item C&lt;MoveFileExW( $swOldName, $swNewName, $uFlags )&gt;

C&lt;$swOldName&gt; and C&lt;$swNewName&gt; are Unicode.

=item QueryDosDeviceW

=item C&lt;$olwTargetLen= QueryDosDeviceW( $swDeviceName, $oswTargetPath, $lwTargetBuf )&gt;

C&lt;$swDeviceName&gt; is Unicode and Unicode is written to
C&lt;$oswTargetPath&gt;.  C&lt;$lwTargetBuf&gt; and C&lt;$olwTargetLen&gt; are measured
as number of  C&lt;WCHAR&gt;s.

=back

=item C&lt;":Misc"&gt;

Miscellaneous constants.  Used for the C&lt;$uCreate&gt; argument of
C&lt;CreateFile&gt; or the C&lt;$uFromWhere&gt; argument of C&lt;SetFilePointer&gt;.
Plus C&lt;INVALID_HANDLE_VALUE&gt;, which you usually won't need to check
for since most routines translate it into a false value.

	CREATE_ALWAYS		CREATE_NEW		OPEN_ALWAYS
	OPEN_EXISTING		TRUNCATE_EXISTING	INVALID_HANDLE_VALUE
	FILE_BEGIN		FILE_CURRENT		FILE_END

=item C&lt;":DDD_"&gt;

Constants for the C&lt;$uFlags&gt; argument of C&lt;DefineDosDevice&gt;.

	DDD_EXACT_MATCH_ON_REMOVE
	DDD_RAW_TARGET_PATH
	DDD_REMOVE_DEFINITION

=item C&lt;":DRIVE_"&gt;

Constants returned by C&lt;GetDriveType&gt;.

	DRIVE_UNKNOWN		DRIVE_NO_ROOT_DIR	DRIVE_REMOVABLE
	DRIVE_FIXED		DRIVE_REMOTE		DRIVE_CDROM
	DRIVE_RAMDISK

=item C&lt;":FILE_"&gt;

Specific types of access to files that can be requested via the
C&lt;$uAccess&gt; argument to C&lt;CreateFile&gt;.

	FILE_READ_DATA			FILE_LIST_DIRECTORY
	FILE_WRITE_DATA			FILE_ADD_FILE
	FILE_APPEND_DATA		FILE_ADD_SUBDIRECTORY
	FILE_CREATE_PIPE_INSTANCE	FILE_READ_EA
	FILE_WRITE_EA			FILE_EXECUTE
	FILE_TRAVERSE			FILE_DELETE_CHILD
	FILE_READ_ATTRIBUTES		FILE_WRITE_ATTRIBUTES
	FILE_ALL_ACCESS			FILE_GENERIC_READ
	FILE_GENERIC_WRITE		FILE_GENERIC_EXECUTE )],

=item C&lt;":FILE_ATTRIBUTE_"&gt;

File attribute constants.  Returned by C&lt;attrLetsToBits&gt; and used in
the C&lt;$uFlags&gt; argument to C&lt;CreateFile&gt;.

	FILE_ATTRIBUTE_ARCHIVE			FILE_ATTRIBUTE_COMPRESSED
	FILE_ATTRIBUTE_HIDDEN			FILE_ATTRIBUTE_NORMAL
	FILE_ATTRIBUTE_OFFLINE			FILE_ATTRIBUTE_READONLY
	FILE_ATTRIBUTE_SYSTEM			FILE_ATTRIBUTE_TEMPORARY

In addition, C&lt;GetFileAttributes&gt; can return these constants (or
INVALID_FILE_ATTRIBUTES in case of an error).

	FILE_ATTRIBUTE_DEVICE			FILE_ATTRIBUTE_DIRECTORY
	FILE_ATTRIBUTE_ENCRYPTED		FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
	FILE_ATTRIBUTE_REPARSE_POINT	FILE_ATTRIBUTE_SPARSE_FILE

=item C&lt;":FILE_FLAG_"&gt;

File option flag constants.  Used in the C&lt;$uFlags&gt; argument to
C&lt;CreateFile&gt;.

	FILE_FLAG_BACKUP_SEMANTICS	FILE_FLAG_DELETE_ON_CLOSE
	FILE_FLAG_NO_BUFFERING		FILE_FLAG_OVERLAPPED
	FILE_FLAG_POSIX_SEMANTICS	FILE_FLAG_RANDOM_ACCESS
	FILE_FLAG_SEQUENTIAL_SCAN	FILE_FLAG_WRITE_THROUGH
	FILE_FLAG_OPEN_REPARSE_POINT

=item C&lt;":FILE_SHARE_"&gt;

File sharing constants.  Used in the C&lt;$uShare&gt; argument to
C&lt;CreateFile&gt;.

	FILE_SHARE_DELETE	FILE_SHARE_READ		FILE_SHARE_WRITE

=item C&lt;":FILE_TYPE_"&gt;

File type constants.  Returned by C&lt;GetFileType&gt;.

	FILE_TYPE_CHAR		FILE_TYPE_DISK
	FILE_TYPE_PIPE		FILE_TYPE_UNKNOWN

=item C&lt;":FS_"&gt;

File system characteristics constants.  Placed in the C&lt;$ouFsFlags&gt;
argument to C&lt;GetVolumeInformation&gt;.

	FS_CASE_IS_PRESERVED		FS_CASE_SENSITIVE
	FS_UNICODE_STORED_ON_DISK	FS_PERSISTENT_ACLS 
	FS_FILE_COMPRESSION		FS_VOL_IS_COMPRESSED

=item C&lt;":HANDLE_FLAG_"&gt;

Flag bits modifying the behavior of an object handle and accessed via
C&lt;GetHandleInformation&gt; and C&lt;SetHandleInformation&gt;.

=over

=item HANDLE_FLAG_INHERIT

If this bit is set, then children of this process who inherit handles
[that is, processes created by calls to the Win32 C&lt;CreateProcess&gt; API
with the C&lt;bInheritHandles&gt; parameter specified as C&lt;TRUE&gt;], will inherit
this particular object handle.

=item HANDLE_FLAG_PROTECT_FROM_CLOSE

If this bit is set, then calls to C&lt;CloseHandle&gt; against this handle
will be ignored, leaving the handle open and usable.

=back

=item C&lt;":IOCTL_STORAGE_"&gt;

I/O control operations for generic storage devices.  Used in the
C&lt;$uIoControlCode&gt; argument to C&lt;DeviceIoControl&gt;.  Includes
C&lt;IOCTL_STORAGE_CHECK_VERIFY&gt;, C&lt;IOCTL_STORAGE_MEDIA_REMOVAL&gt;,
C&lt;IOCTL_STORAGE_EJECT_MEDIA&gt;, C&lt;IOCTL_STORAGE_LOAD_MEDIA&gt;,
C&lt;IOCTL_STORAGE_RESERVE&gt;, C&lt;IOCTL_STORAGE_RELEASE&gt;,
C&lt;IOCTL_STORAGE_FIND_NEW_DEVICES&gt;, and
C&lt;IOCTL_STORAGE_GET_MEDIA_TYPES&gt;.

=over

=item C&lt;IOCTL_STORAGE_CHECK_VERIFY&gt;

Verify that a device's media is accessible.  C&lt;$pInBuf&gt; and C&lt;$opOutBuf&gt;
should both be C&lt;[]&gt;.  If C&lt;DeviceIoControl&gt; returns a true value, then
the media is currently accessible.

=item C&lt;IOCTL_STORAGE_MEDIA_REMOVAL&gt;

Allows the device's media to be locked or unlocked.  C&lt;$opOutBuf&gt; should
be C&lt;[]&gt;.  C&lt;$pInBuf&gt; should be a C&lt;PREVENT_MEDIA_REMOVAL&gt; data structure,
which is simply an integer containing a boolean value:

    $pInBuf= pack( "i", $bPreventMediaRemoval );

=item C&lt;IOCTL_STORAGE_EJECT_MEDIA&gt;

Requests that the device eject the media.  C&lt;$pInBuf&gt; and C&lt;$opOutBuf&gt;
should both be C&lt;[]&gt;.  

=item C&lt;IOCTL_STORAGE_LOAD_MEDIA&gt;

Requests that the device load the media.  C&lt;$pInBuf&gt; and C&lt;$opOutBuf&gt;
should both be C&lt;[]&gt;.

=item C&lt;IOCTL_STORAGE_RESERVE&gt;

Requests that the device be reserved.  C&lt;$pInBuf&gt; and C&lt;$opOutBuf&gt;
should both be C&lt;[]&gt;.

=item C&lt;IOCTL_STORAGE_RELEASE&gt;

Releases a previous device reservation.  C&lt;$pInBuf&gt; and C&lt;$opOutBuf&gt;
should both be C&lt;[]&gt;.

=item C&lt;IOCTL_STORAGE_FIND_NEW_DEVICES&gt;

No documentation on this IOCTL operation was found.

=item C&lt;IOCTL_STORAGE_GET_MEDIA_TYPES&gt;

Requests information about the type of media supported by the device. 
C&lt;$pInBuf&gt; should be C&lt;[]&gt;.  C&lt;$opOutBuf&gt; will be set to contain a
vector of C&lt;DISK_GEOMETRY&gt; data structures, which can be decoded via:

    # Calculate the number of DISK_GEOMETRY structures returned:
    my $cStructs= length($opOutBuf)/(4+4+4+4+4+4);
    my @fields= unpack( "L l I L L L" x $cStructs, $opOutBuf )
    my( @ucCylsLow, @ivcCylsHigh, @uMediaType, @uTracksPerCyl,
      @uSectsPerTrack, @uBytesPerSect )= ();
    while(  @fields  ) {
	push( @ucCylsLow, unshift @fields );
	push( @ivcCylsHigh, unshift @fields );
	push( @uMediaType, unshift @fields );
	push( @uTracksPerCyl, unshift @fields );
	push( @uSectsPerTrack, unshift @fields );
	push( @uBytesPerSect, unshift @fields );
    }

For the C&lt;$i&gt;th type of supported media, the following variables will
contain the following data.

=over

=item C&lt;$ucCylsLow[$i]&gt;

The low-order 4 bytes of the total number of cylinders.

=item C&lt;$ivcCylsHigh[$i]&gt; 

The high-order 4 bytes of the total number of cylinders.

=item C&lt;$uMediaType[$i]&gt;

A code for the type of media.  See the C&lt;":MEDIA_TYPE"&gt; export class.

=item C&lt;$uTracksPerCyl[$i]&gt;

The number of tracks in each cylinder.

=item C&lt;$uSectsPerTrack[$i]&gt;

The number of sectors in each track.

=item C&lt;$uBytesPerSect[$i]&gt;

The number of bytes in each sector.

=back

=back

=item C&lt;":IOCTL_DISK_"&gt;

I/O control operations for disk devices.  Used in the C&lt;$uIoControlCode&gt;
argument to C&lt;DeviceIoControl&gt;.  Most of these are to be used on
physical drive devices like C&lt;"//./PhysicalDrive0"&gt;.  However,
C&lt;IOCTL_DISK_GET_PARTITION_INFO&gt; and C&lt;IOCTL_DISK_SET_PARTITION_INFO&gt;
should only be used on a single-partition device like C&lt;"//./C:"&gt;.  Also,
C&lt;IOCTL_DISK_GET_MEDIA_TYPES&gt; is documented as having been superseded but
is still useful when used on a floppy device like C&lt;"//./A:"&gt;.

Includes C&lt;IOCTL_DISK_FORMAT_TRACKS&gt;, C&lt;IOCTL_DISK_FORMAT_TRACKS_EX&gt;,
C&lt;IOCTL_DISK_GET_DRIVE_GEOMETRY&gt;, C&lt;IOCTL_DISK_GET_DRIVE_LAYOUT&gt;,
C&lt;IOCTL_DISK_GET_MEDIA_TYPES&gt;, C&lt;IOCTL_DISK_GET_PARTITION_INFO&gt;,
C&lt;IOCTL_DISK_HISTOGRAM_DATA&gt;, C&lt;IOCTL_DISK_HISTOGRAM_RESET&gt;,
C&lt;IOCTL_DISK_HISTOGRAM_STRUCTURE&gt;, C&lt;IOCTL_DISK_IS_WRITABLE&gt;,
C&lt;IOCTL_DISK_LOGGING&gt;, C&lt;IOCTL_DISK_PERFORMANCE&gt;,
C&lt;IOCTL_DISK_REASSIGN_BLOCKS&gt;, C&lt;IOCTL_DISK_REQUEST_DATA&gt;,
C&lt;IOCTL_DISK_REQUEST_STRUCTURE&gt;, C&lt;IOCTL_DISK_SET_DRIVE_LAYOUT&gt;,
C&lt;IOCTL_DISK_SET_PARTITION_INFO&gt;, and C&lt;IOCTL_DISK_VERIFY&gt;.

=over

=item C&lt;IOCTL_DISK_GET_DRIVE_GEOMETRY&gt;

Request information about the size and geometry of the disk.  C&lt;$pInBuf&gt;
should be C&lt;[]&gt;.  C&lt;$opOutBuf&gt; will be set to a C&lt;DISK_GEOMETRY&gt; data
structure which can be decode via:

    ( $ucCylsLow, $ivcCylsHigh, $uMediaType, $uTracksPerCyl,
      $uSectsPerTrack, $uBytesPerSect )= unpack( "L l I L L L", $opOutBuf );

=over

=item C&lt;$ucCylsLow&gt;

The low-order 4 bytes of the total number of cylinders.

=item C&lt;$ivcCylsHigh&gt; 

The high-order 4 bytes of the total number of cylinders.

=item C&lt;$uMediaType&gt;

A code for the type of media.  See the C&lt;":MEDIA_TYPE"&gt; export class.

=item C&lt;$uTracksPerCyl&gt;

The number of tracks in each cylinder.

=item C&lt;$uSectsPerTrack&gt;

The number of sectors in each track.

=item C&lt;$uBytesPerSect&gt;

The number of bytes in each sector.

=back

=item C&lt;IOCTL_DISK_GET_PARTITION_INFO&gt;

Request information about the size and geometry of the partition. 
C&lt;$pInBuf&gt; should be C&lt;[]&gt;.  C&lt;$opOutBuf&gt; will be set to a
C&lt;PARTITION_INFORMATION&gt; data structure which can be decode via:

    ( $uStartLow, $ivStartHigh, $ucHiddenSects, $uPartitionSeqNumber,
      $uPartitionType, $bActive, $bRecognized, $bToRewrite )=
      unpack( "L l L L C c c c", $opOutBuf );

=over

=item C&lt;$uStartLow&gt; and C&lt;$ivStartHigh&gt;

The low-order and high-order [respectively] 4 bytes of the starting
offset of the partition, measured in bytes.

=item C&lt;$ucHiddenSects&gt;

The number of "hidden" sectors for this partition.  Actually this is
the number of sectors found prior to this partition, that is, the
starting offset [as found in C&lt;$uStartLow&gt; and C&lt;$ivStartHigh&gt;]
divided by the number of bytes per sector.

=item C&lt;$uPartitionSeqNumber&gt;

The sequence number of this partition.  Partitions are numbered
starting as C&lt;1&gt; [with "partition 0" meaning the entire disk].  
Sometimes this field may be C&lt;0&gt; and you'll have to infer the
partition sequence number from how many partitions precede it on
the disk.

=item C&lt;$uPartitionType&gt;

The type of partition.  See the C&lt;":PARTITION_"&gt; export class for a
list of known types.  See also C&lt;IsRecognizedPartition&gt; and
C&lt;IsContainerPartition&gt;.

=item C&lt;$bActive&gt;

C&lt;1&gt; for the active [boot] partition, C&lt;0&gt; otherwise.

=item C&lt;$bRecognized&gt;

Whether this type of partition is support under Win32.

=item C&lt;$bToRewrite&gt;

Whether to update this partition information.  This field is not used
by C&lt;IOCTL_DISK_GET_PARTITION_INFO&gt;.  For
C&lt;IOCTL_DISK_SET_DRIVE_LAYOUT&gt;, you must set this field to a true
value for any partitions you wish to have changed, added, or deleted.

=back

=item C&lt;IOCTL_DISK_SET_PARTITION_INFO&gt;

Change the type of the partition.  C&lt;$opOutBuf&gt; should be C&lt;[]&gt;.
C&lt;$pInBuf&gt; should be a C&lt;SET_PARTITION_INFORMATION&gt; data structure
which is just a single byte containing the new partition type [see
the C&lt;":PARTITION_"&gt; export class for a list of known types]:

    $pInBuf= pack( "C", $uPartitionType );

=item C&lt;IOCTL_DISK_GET_DRIVE_LAYOUT&gt;

Request information about the disk layout.  C&lt;$pInBuf&gt; should be C&lt;[]&gt;.
C&lt;$opOutBuf&gt; will be set to contain C&lt;DRIVE_LAYOUT_INFORMATION&gt;
structure including several C&lt;PARTITION_INFORMATION&gt; structures:

    my( $cPartitions, $uDiskSignature )= unpack( "L L", $opOutBuf );
    my @fields= unpack( "x8" . ( "L l L L C c c c" x $cPartitions ),
		        $opOutBuf );
    my( @uStartLow, @ivStartHigh, @ucHiddenSects,
      @uPartitionSeqNumber, @uPartitionType, @bActive,
      @bRecognized, @bToRewrite )= ();
    for(  1..$cPartition  ) {
	push( @uStartLow, unshift @fields );
	push( @ivStartHigh, unshift @fields );
	push( @ucHiddenSects, unshift @fields );
	push( @uPartitionSeqNumber, unshift @fields );
	push( @uPartitionType, unshift @fields );
	push( @bActive, unshift @fields );
	push( @bRecognized, unshift @fields );
	push( @bToRewrite, unshift @fields );
    }

=over

=item C&lt;$cPartitions&gt;

If the number of partitions on the disk.

=item C&lt;$uDiskSignature&gt;

Is the disk signature, a unique number assigned by Disk Administrator
[F&lt;WinDisk.exe&gt;] and used to identify the disk.  This allows drive
letters for partitions on that disk to remain constant even if the
SCSI Target ID of the disk gets changed.

=back

See C&lt;IOCTL_DISK_GET_PARTITION_INFORMATION&gt; for information on the
remaining these fields.

=item C&lt;IOCTL_DISK_GET_MEDIA_TYPES&gt;

Is supposed to be superseded by C&lt;IOCTL_STORAGE_GET_MEDIA_TYPES&gt; but
is still useful for determining the types of floppy diskette formats
that can be produced by a given floppy drive.  See
F&lt;ex/FormatFloppy.plx&gt; for an example.

=item C&lt;IOCTL_DISK_SET_DRIVE_LAYOUT&gt;

Change the partition layout of the disk.  C&lt;$pOutBuf&gt; should be C&lt;[]&gt;.
C&lt;$pInBuf&gt; should be a C&lt;DISK_LAYOUT_INFORMATION&gt; data structure
including several C&lt;PARTITION_INFORMATION&gt; data structures.

    # Already set:  $cPartitions, $uDiskSignature, @uStartLow, @ivStartHigh,
    #   @ucHiddenSects, @uPartitionSeqNumber, @uPartitionType, @bActive,
    #   @bRecognized, and @bToRewrite.
    my( @fields, $prtn )= ();
    for $prtn (  1..$cPartition  ) {
	push( @fields, $uStartLow[$prtn-1], $ivStartHigh[$prtn-1],
	    $ucHiddenSects[$prtn-1], $uPartitionSeqNumber[$prtn-1],
	    $uPartitionType[$prtn-1], $bActive[$prtn-1],
	    $bRecognized[$prtn-1], $bToRewrite[$prtn-1] );
    }
    $pInBuf= pack( "L L" . ( "L l L L C c c c" x $cPartitions ),
		   $cPartitions, $uDiskSignature, @fields );

To delete a partition, zero out all fields except for C&lt;$bToRewrite&gt;
which should be set to C&lt;1&gt;.  To add a partition, increment
C&lt;$cPartitions&gt; and add the information for the new partition
into the arrays, making sure that you insert C&lt;1&gt; into @bToRewrite.

See C&lt;IOCTL_DISK_GET_DRIVE_LAYOUT&gt; and
C&lt;IOCTL_DISK_GET_PARITITON_INFORMATION&gt; for descriptions of the
fields.

=item C&lt;IOCTL_DISK_VERIFY&gt;

Performs a logical format of [part of] the disk.  C&lt;$opOutBuf&gt; should
be C&lt;[]&gt;.  C&lt;$pInBuf&gt; should contain a C&lt;VERIFY_INFORMATION&gt; data
structure:

    $pInBuf= pack( "L l L",
		   $uStartOffsetLow, $ivStartOffsetHigh, $uLength );

=over

=item C&lt;$uStartOffsetLow&gt; and C&lt;$ivStartOffsetHigh&gt;

The low-order and high-order [respectively] 4 bytes of the offset [in
bytes] where the formatting should begin.

=item C&lt;$uLength&gt;

The length [in bytes] of the section to be formatted.

=back

=item C&lt;IOCTL_DISK_FORMAT_TRACKS&gt;

Format a range of tracks on the disk.  C&lt;$opOutBuf&gt; should be C&lt;[]&gt;. 
C&lt;$pInBuf&gt; should contain a C&lt;FORMAT_PARAMETERS&gt; data structure:

    $pInBuf= pack( "L L L L L", $uMediaType,
		   $uStartCyl, $uEndCyl, $uStartHead, $uEndHead );

C&lt;$uMediaType&gt; if the type of media to be formatted.  Mostly used to
specify the density to use when formatting a floppy diskette.  See the
C&lt;":MEDIA_TYPE"&gt; export class for more information.

The remaining fields specify the starting and ending cylinder and
head of the range of tracks to be formatted.

=item C&lt;IOCTL_DISK_REASSIGN_BLOCKS&gt;

Reassign a list of disk blocks to the disk's spare-block pool. 
C&lt;$opOutBuf&gt; should be C&lt;[]&gt;.  C&lt;$pInBuf&gt; should be a
C&lt;REASSIGN_BLOCKS&gt; data structure:

    $pInBuf= pack( "S S L*", 0, $cBlocks, @uBlockNumbers );

=item C&lt;IOCTL_DISK_PERFORMANCE&gt;

Request information about disk performance.  C&lt;$pInBuf&gt; should be C&lt;[]&gt;.
C&lt;$opOutBuf&gt; will be set to contain a C&lt;DISK_PERFORMANCE&gt; data structure:

    my( $ucBytesReadLow, $ivcBytesReadHigh,
	$ucBytesWrittenLow, $ivcBytesWrittenHigh,
	$uReadTimeLow, $ivReadTimeHigh,
	$uWriteTimeLow, $ivWriteTimeHigh,
	$ucReads, $ucWrites, $uQueueDepth )=
	unpack( "L l L l L l L l L L L", $opOutBuf );

=item C&lt;IOCTL_DISK_IS_WRITABLE&gt;

No documentation on this IOCTL operation was found.

=item C&lt;IOCTL_DISK_LOGGING&gt;

Control disk logging.  Little documentation for this IOCTL operation
was found.  It makes use of a C&lt;DISK_LOGGING&gt; data structure:

=over

=item DISK_LOGGING_START

Start logging each disk request in a buffer internal to the disk device
driver of size C&lt;$uLogBufferSize&gt;:

    $pInBuf= pack( "C L L", 0, 0, $uLogBufferSize );

=item DISK_LOGGING_STOP

Stop logging each disk request:

    $pInBuf= pack( "C L L", 1, 0, 0 );

=item DISK_LOGGING_DUMP

Copy the internal log into the supplied buffer:

    $pLogBuffer= ' ' x $uLogBufferSize
    $pInBuf= pack( "C P L", 2, $pLogBuffer, $uLogBufferSize );

    ( $uByteOffsetLow[$i], $ivByteOffsetHigh[$i],
      $uStartTimeLow[$i], $ivStartTimeHigh[$i],
      $uEndTimeLog[$i], $ivEndTimeHigh[$i],
      $hVirtualAddress[$i], $ucBytes[$i],
      $uDeviceNumber[$i], $bWasReading[$i] )=
      unpack( "x".(8+8+8+4+4+1+1+2)." L l L l L l L L C c x2", $pLogBuffer );

=item DISK_LOGGING_BINNING

Keep statics grouped into bins based on request sizes.

    $pInBuf= pack( "C P L", 3, $pUnknown, $uUnknownSize );

=back

=item C&lt;IOCTL_DISK_FORMAT_TRACKS_EX&gt;

No documentation on this IOCTL is included.

=item C&lt;IOCTL_DISK_HISTOGRAM_STRUCTURE&gt;

No documentation on this IOCTL is included.

=item C&lt;IOCTL_DISK_HISTOGRAM_DATA&gt;

No documentation on this IOCTL is included.

=item C&lt;IOCTL_DISK_HISTOGRAM_RESET&gt;

No documentation on this IOCTL is included.

=item C&lt;IOCTL_DISK_REQUEST_STRUCTURE&gt;

No documentation on this IOCTL operation was found.

=item C&lt;IOCTL_DISK_REQUEST_DATA&gt;

No documentation on this IOCTL operation was found.

=back

=item C&lt;":FSCTL_"&gt;

File system control operations.  Used in the C&lt;$uIoControlCode&gt;
argument to C&lt;DeviceIoControl&gt;.

Includes C&lt;FSCTL_SET_REPARSE_POINT&gt;, C&lt;FSCTL_GET_REPARSE_POINT&gt;,
C&lt;FSCTL_DELETE_REPARSE_POINT&gt;.

=over

=item C&lt;FSCTL_SET_REPARSE_POINT&gt;

Sets reparse point data to be associated with $hDevice.

=item C&lt;FSCTL_GET_REPARSE_POINT&gt;

Retrieves the reparse point data associated with $hDevice.

=item C&lt;FSCTL_DELETE_REPARSE_POINT&gt;

Deletes the reparse point data associated with $hDevice.

=back

=item C&lt;":GENERIC_"&gt;

Constants specifying generic access permissions that are not specific
to one type of object.

	GENERIC_ALL			GENERIC_EXECUTE
	GENERIC_READ		GENERIC_WRITE

=item C&lt;":MEDIA_TYPE"&gt;

Different classes of media that a device can support.  Used in the
C&lt;$uMediaType&gt; field of a C&lt;DISK_GEOMETRY&gt; structure.

=over

=item C&lt;Unknown&gt;

Format is unknown.

=item C&lt;F5_1Pt2_512&gt;

5.25" floppy, 1.2MB [really 1,200KB] total space, 512 bytes/sector.

=item C&lt;F3_1Pt44_512&gt;

3.5" floppy, 1.44MB [really 1,440KB] total space, 512 bytes/sector.

=item C&lt;F3_2Pt88_512&gt;

3.5" floppy, 2.88MB [really 2,880KB] total space, 512 bytes/sector.

=item C&lt;F3_20Pt8_512&gt;

3.5" floppy, 20.8MB total space, 512 bytes/sector.

=item C&lt;F3_720_512&gt;

3.5" floppy, 720KB total space, 512 bytes/sector.

=item C&lt;F5_360_512&gt;

5.25" floppy, 360KB total space, 512 bytes/sector.

=item C&lt;F5_320_512&gt;

5.25" floppy, 320KB total space, 512 bytes/sector.

=item C&lt;F5_320_1024&gt;

5.25" floppy, 320KB total space, 1024 bytes/sector.

=item C&lt;F5_180_512&gt;

5.25" floppy, 180KB total space, 512 bytes/sector.

=item C&lt;F5_160_512&gt;

5.25" floppy, 160KB total space, 512 bytes/sector.

=item C&lt;RemovableMedia&gt;

Some type of removable media other than a floppy diskette.

=item C&lt;FixedMedia&gt;

A fixed hard disk.

=item C&lt;F3_120M_512&gt;

3.5" floppy, 120MB total space.

=back

=item C&lt;":MOVEFILE_"&gt;

Constants for use in C&lt;$uFlags&gt; arguments to C&lt;MoveFileEx&gt;.

	MOVEFILE_COPY_ALLOWED		MOVEFILE_DELAY_UNTIL_REBOOT
	MOVEFILE_REPLACE_EXISTING	MOVEFILE_WRITE_THROUGH

=item C&lt;":SECURITY_"&gt;

Security quality of service values that can be used in the C&lt;$uFlags&gt;
argument to C&lt;CreateFile&gt; if opening the client side of a named pipe.

	SECURITY_ANONYMOUS		SECURITY_CONTEXT_TRACKING
	SECURITY_DELEGATION		SECURITY_EFFECTIVE_ONLY
	SECURITY_IDENTIFICATION		SECURITY_IMPERSONATION
	SECURITY_SQOS_PRESENT

=item C&lt;":SEM_"&gt;

Constants to be used with C&lt;SetErrorMode&gt;.

	SEM_FAILCRITICALERRORS		SEM_NOGPFAULTERRORBOX
	SEM_NOALIGNMENTFAULTEXCEPT	SEM_NOOPENFILEERRORBOX

=item C&lt;":PARTITION_"&gt;

Constants describing partition types.

	PARTITION_ENTRY_UNUSED		PARTITION_FAT_12
	PARTITION_XENIX_1		PARTITION_XENIX_2
	PARTITION_FAT_16		PARTITION_EXTENDED
	PARTITION_HUGE			PARTITION_IFS
	PARTITION_FAT32			PARTITION_FAT32_XINT13
	PARTITION_XINT13		PARTITION_XINT13_EXTENDED
	PARTITION_PREP			PARTITION_UNIX
	VALID_NTFT			PARTITION_NTFT

=item C&lt;":STD_HANDLE_"&gt;

Constants for GetStdHandle and SetStdHandle

    STD_ERROR_HANDLE
    STD_INPUT_HANDLE
    STD_OUTPUT_HANDLE

=item C&lt;":ALL"&gt;

All of the above.

=back

=head1 BUGS

None known at this time.

=head1 AUTHOR

Tye McQueen, tye@metronet.com, http://perlmonks.org/?node=tye.

=head1 SEE ALSO

The pyramids.

=cut
</pre></body></html>