Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
9.2 KiB

  1. =head1 NAME
  2. Win32 - Interfaces to some Win32 API Functions
  3. =head1 DESCRIPTION
  4. Perl on Win32 contains several functions to access Win32 APIs. Some
  5. are included in Perl itself (on Win32) and some are only available
  6. after explicitly requesting the Win32 module with:
  7. use Win32;
  8. The builtin functions are marked as [CORE] and the other ones
  9. as [EXT] in the following alphabetical listing. The C<Win32> module
  10. is not part of the Perl source distribution; it is distributed in
  11. the libwin32 bundle of Win32::* modules on CPAN. The module is
  12. already preinstalled in binary distributions like ActivePerl.
  13. =head2 Alphabetical Listing of Win32 Functions
  14. =over
  15. =item Win32::AbortSystemShutdown(MACHINE)
  16. [EXT] Aborts a system shutdown (started by the
  17. InitiateSystemShutdown function) on the specified MACHINE.
  18. =item Win32::BuildNumber()
  19. [CORE] Returns the ActivePerl build number. This function is
  20. only available in the ActivePerl binary distribution.
  21. =item Win32::CopyFile(FROM, TO, OVERWRITE)
  22. The Win32::CopyFile() function copies an existing file to a new file. All
  23. file information like creation time and file attributes will be copied to
  24. the new file. However it will B<not> copy the security information. If the
  25. destination file already exists it will only be overwritten when the
  26. OVERWRITE parameter is true. But even this will not overwrite a read-only
  27. file; you have to unlink() it first yourself.
  28. =item Win32::DomainName()
  29. [CORE] Returns the name of the Microsoft Network domain that the
  30. owner of the current perl process is logged into.
  31. =item Win32::ExpandEnvironmentStrings(STRING)
  32. [EXT] Takes STRING and replaces all referenced environment variable
  33. names with their defined values. References to environment variables
  34. take the form C<%VariableName%>. Case is ignored when looking up the
  35. VariableName in the environment. If the variable is not found then the
  36. original C<%VariableName%> text is retained. Has the same effect
  37. as the following:
  38. $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg
  39. =item Win32::FormatMessage(ERRORCODE)
  40. [CORE] Converts the supplied Win32 error number (e.g. returned by
  41. Win32::GetLastError()) to a descriptive string. Analogous to the
  42. perror() standard-C library function. Note that C<$^E> used
  43. in a string context has much the same effect.
  44. C:\> perl -e "$^E = 26; print $^E;"
  45. The specified disk or diskette cannot be accessed
  46. =item Win32::FsType()
  47. [CORE] Returns the name of the filesystem of the currently active
  48. drive (like 'FAT' or 'NTFS'). In list context it returns three values:
  49. (FSTYPE, FLAGS, MAXCOMPLEN). FSTYPE is the filesystem type as
  50. before. FLAGS is a combination of values of the following table:
  51. 0x00000001 supports case-sensitive filenames
  52. 0x00000002 preserves the case of filenames
  53. 0x00000004 supports Unicode in filenames
  54. 0x00000008 preserves and enforces ACLs
  55. 0x00000010 supports file-based compression
  56. 0x00000020 supports disk quotas
  57. 0x00000040 supports sparse files
  58. 0x00000080 supports reparse points
  59. 0x00000100 supports remote storage
  60. 0x00008000 is a compressed volume (e.g. DoubleSpace)
  61. 0x00010000 supports object identifiers
  62. 0x00020000 supports the Encrypted File System (EFS)
  63. MAXCOMPLEN is the maximum length of a filename component (the part
  64. between two backslashes) on this file system.
  65. =item Win32::FreeLibrary(HANDLE)
  66. [EXT] Unloads a previously loaded dynamic-link library. The HANDLE is
  67. no longer valid after this call. See L<LoadLibrary> for information on
  68. dynamically loading a library.
  69. =item Win32::GetArchName()
  70. [EXT] Use of this function is deprecated. It is equivalent with
  71. $ENV{PROCESSOR_ARCHITECTURE}. This might not work on Win9X.
  72. =item Win32::GetChipName()
  73. [EXT] Returns the processor type: 386, 486 or 586 for Intel processors,
  74. 21064 for the Alpha chip.
  75. =item Win32::GetCwd()
  76. [CORE] Returns the current active drive and directory. This function
  77. does not return a UNC path, since the functionality required for such
  78. a feature is not available under Windows 95.
  79. =item Win32::GetFullPathName(FILENAME)
  80. [CORE] GetFullPathName combines the FILENAME with the current drive
  81. and directory name and returns a fully qualified (aka, absolute)
  82. path name. In list context it returns two elements: (PATH, FILE) where
  83. PATH is the complete pathname component (including trailing backslash)
  84. and FILE is just the filename part. Note that no attempt is made to
  85. convert 8.3 components in the supplied FILENAME to longnames or
  86. vice-versa. Compare with Win32::GetShortPathName and
  87. Win32::GetLongPathName.
  88. This function has been added for Perl 5.006.
  89. =item Win32::GetLastError()
  90. [CORE] Returns the last error value generated by a call to a Win32 API
  91. function. Note that C<$^E> used in a numeric context amounts to the
  92. same value.
  93. =item Win32::GetLongPathName(PATHNAME)
  94. [CORE] Returns a representaion of PATHNAME comprised of longname
  95. compnents (if any). The result may not necessarily be longer
  96. than PATHNAME. No attempt is made to convert PATHNAME to the
  97. absolute path. Compare with Win32::GetShortPathName and
  98. Win32::GetFullPathName.
  99. This function has been added for Perl 5.006.
  100. =item Win32::GetNextAvailDrive()
  101. [CORE] Returns a string in the form of "<d>:" where <d> is the first
  102. available drive letter.
  103. =item Win32::GetOSVersion()
  104. [CORE] Returns the array (STRING, MAJOR, MINOR, BUILD, ID), where
  105. the elements are, respectively: An arbitrary descriptive string, the
  106. major version number of the operating system, the minor version
  107. number, the build number, and a digit indicating the actual operating
  108. system. For ID, the values are 0 for Win32s, 1 for Windows 9X and 2
  109. for Windows NT. In scalar context it returns just the ID.
  110. =item Win32::GetShortPathName(PATHNAME)
  111. [CORE] Returns a representation of PATHNAME comprised only of
  112. short (8.3) path components. The result may not necessarily be
  113. shorter than PATHNAME. Compare with Win32::GetFullPathName and
  114. Win32::GetLongPathName.
  115. =item Win32::GetProcAddress(INSTANCE, PROCNAME)
  116. [EXT] Returns the address of a function inside a loaded library. The
  117. information about what you can do with this address has been lost in
  118. the mist of time. Use the Win32::API module instead of this deprecated
  119. function.
  120. =item Win32::GetTickCount()
  121. [CORE] Returns the number of milliseconds elapsed since the last
  122. system boot. Resolution is limited to system timer ticks (about 10ms
  123. on WinNT and 55ms on Win9X).
  124. =item Win32::InitiateSystemShutdown(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)
  125. [EXT] Shutsdown the specified MACHINE, notifying users with the
  126. supplied MESSAGE, within the specified TIMEOUT interval. Forces
  127. closing of all documents without prompting the user if FORCECLOSE is
  128. true, and reboots the machine if REBOOT is true. This function works
  129. only on WinNT.
  130. =item Win32::IsWinNT()
  131. [CORE] Returns non zero if the Win32 subsystem is Windows NT.
  132. =item Win32::IsWin95()
  133. [CORE] Returns non zero if the Win32 subsystem is Windows 95.
  134. =item Win32::LoadLibrary(LIBNAME)
  135. [EXT] Loads a dynamic link library into memory and returns its module
  136. handle. This handle can be used with Win32::GetProcAddress and
  137. Win32::FreeLibrary. This function is deprecated. Use the Win32::API
  138. module instead.
  139. =item Win32::LoginName()
  140. [CORE] Returns the username of the owner of the current perl process.
  141. =item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE)
  142. [EXT] Looks up ACCOUNT on SYSTEM and returns the domain name the SID and
  143. the SID type.
  144. =item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE)
  145. [EXT] ]Looks up SID on SYSTEM and returns the account name, domain name,
  146. and the SID type.
  147. =item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])
  148. [EXT] Create a dialogbox containing MESSAGE. FLAGS specifies the
  149. required icon and buttons according to the following table:
  150. 0 = OK
  151. 1 = OK and Cancel
  152. 2 = Abort, Retry, and Ignore
  153. 3 = Yes, No and Cancel
  154. 4 = Yes and No
  155. 5 = Retry and Cancel
  156. MB_ICONSTOP "X" in a red circle
  157. MB_ICONQUESTION question mark in a bubble
  158. MB_ICONEXCLAMATION exclamation mark in a yellow triangle
  159. MB_ICONINFORMATION "i" in a bubble
  160. TITLE specifies an optional window title. The default is "Perl".
  161. The function returns the menu id of the selected push button:
  162. 0 Error
  163. 1 OK
  164. 2 Cancel
  165. 3 Abort
  166. 4 Retry
  167. 5 Ignore
  168. 6 Yes
  169. 7 No
  170. =item Win32::NodeName()
  171. [CORE] Returns the Microsoft Network node-name of the current machine.
  172. =item Win32::RegisterServer(LIBRARYNAME)
  173. [EXT] Loads the DLL LIBRARYNAME and calls the function DllRegisterServer.
  174. =item Win32::SetCwd(NEWDIRECTORY)
  175. [CORE] Sets the current active drive and directory. This function does not
  176. work with UNC paths, since the functionality required to required for
  177. such a feature is not available under Windows 95.
  178. =item Win32::SetLastError(ERROR)
  179. [CORE] Sets the value of the last error encountered to ERROR. This is
  180. that value that will be returned by the Win32::GetLastError()
  181. function. This functions has been added for Perl 5.006.
  182. =item Win32::Sleep(TIME)
  183. [CORE] Pauses for TIME milliseconds. The timeslices are made available
  184. to other processes and threads.
  185. =item Win32::Spawn(COMMAND, ARGS, PID)
  186. [CORE] Spawns a new process using the supplied COMMAND, passing in
  187. arguments in the string ARGS. The pid of the new process is stored in
  188. PID. This function is deprecated. Please use the Win32::Process module
  189. instead.
  190. =item Win32::UnregisterServer(LIBRARYNAME)
  191. [EXT] Loads the DLL LIBRARYNAME and calls the function
  192. DllUnregisterServer.
  193. =back
  194. =cut