You are viewing the version of this documentation from Perl 5.42.1. View the latest version

CONTENTS

NAME

Win32 - Interfaces to some Win32 API Functions

DESCRIPTION

The Win32 module contains functions to access Win32 APIs.

Alphabetical Listing of Win32 Functions

It is recommended to use Win32; before any of these functions; however, for backwards compatibility, those marked as [CORE] will automatically do this for you.

In the function descriptions below the term Unicode string is used to indicate that the string may contain characters outside the system codepage. The caveat If supported by the core Perl version generally means Perl 5.8.9 and later, though some Unicode pathname functionality may work on earlier versions.

Win32::AbortSystemShutdown(MACHINE)

Aborts a system shutdown (started by the InitiateSystemShutdown function) on the specified MACHINE.

Win32::BuildNumber()

[CORE] Returns the ActivePerl build number. This function is only available in the ActivePerl binary distribution.

Win32::CopyFile(FROM, TO, OVERWRITE)

[CORE] The Win32::CopyFile() function copies an existing file to a new file. All file information like creation time and file attributes will be copied to the new file. However it will not copy the security information. If the destination file already exists it will only be overwritten when the OVERWRITE parameter is true. But even this will not overwrite a read-only file; you have to unlink() it first yourself.

Win32::CreateDirectory(DIRECTORY)

Creates the DIRECTORY and returns a true value on success. Check $^E on failure for extended error information.

DIRECTORY may contain Unicode characters outside the system codepage. Once the directory has been created you can use Win32::GetANSIPathName() to get a name that can be passed to system calls and external programs.

Win32::CreateFile(FILE)

Creates the FILE and returns a true value on success. Check $^E on failure for extended error information.

FILE may contain Unicode characters outside the system codepage. Once the file has been created you can use Win32::GetANSIPathName() to get a name that can be passed to system calls and external programs.

Win32::DomainName()

[CORE] Returns the name of the Microsoft Network domain or workgroup that the owner of the current perl process is logged into. The "Workstation" service must be running to determine this information. This function does not work on Windows 9x.

Win32::ExpandEnvironmentStrings(STRING)

Takes STRING and replaces all referenced environment variable names with their defined values. References to environment variables take the form %VariableName%. Case is ignored when looking up the VariableName in the environment. If the variable is not found then the original %VariableName% text is retained. Has the same effect as the following:

$string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg

However, this function may return a Unicode string if the environment variable being expanded hasn't been assigned to via %ENV. Access to %ENV is currently always using byte semantics.

Win32::FormatMessage(ERRORCODE)

[CORE] Converts the supplied Win32 error number (e.g. returned by Win32::GetLastError()) to a descriptive string. Analogous to the perror() standard-C library function. Note that $^E used in a string context has much the same effect.

C:\> perl -e "$^E = 26; print $^E;"
The specified disk or diskette cannot be accessed
Win32::FsType()

[CORE] Returns the name of the filesystem of the currently active drive (like 'FAT' or 'NTFS'). In list context it returns three values: (FSTYPE, FLAGS, MAXCOMPLEN). FSTYPE is the filesystem type as before. FLAGS is a combination of values of the following table:

0x00000001  supports case-sensitive filenames
0x00000002  preserves the case of filenames
0x00000004  supports Unicode in filenames
0x00000008  preserves and enforces ACLs
0x00000010  supports file-based compression
0x00000020  supports disk quotas
0x00000040  supports sparse files
0x00000080  supports reparse points
0x00000100  supports remote storage
0x00008000  is a compressed volume (e.g. DoubleSpace)
0x00010000  supports object identifiers
0x00020000  supports the Encrypted File System (EFS)

MAXCOMPLEN is the maximum length of a filename component (the part between two backslashes) on this file system.

Win32::FreeLibrary(HANDLE)

Unloads a previously loaded dynamic-link library. The HANDLE is no longer valid after this call. See LoadLibrary for information on dynamically loading a library.

Win32::GetACP()

Returns the current Windows ANSI code page identifier for the operating system. See also GetOEMCP(), GetConsoleCP() and GetConsoleOutputCP().