Update IPC::Cmd to cpan version 0.54
[p5sagit/p5-mst-13.2.git] / cpan / Win32 / Win32.pm
1 package Win32;\r
2 \r
3 BEGIN {\r
4     use strict;\r
5     use vars qw|$VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK|;\r
6 \r
7     require Exporter;\r
8     require DynaLoader;\r
9 \r
10     @ISA = qw|Exporter DynaLoader|;\r
11     $VERSION = '0.39';\r
12     $XS_VERSION = $VERSION;\r
13     $VERSION = eval $VERSION;\r
14 \r
15     @EXPORT = qw(\r
16         NULL\r
17         WIN31_CLASS\r
18         OWNER_SECURITY_INFORMATION\r
19         GROUP_SECURITY_INFORMATION\r
20         DACL_SECURITY_INFORMATION\r
21         SACL_SECURITY_INFORMATION\r
22         MB_ICONHAND\r
23         MB_ICONQUESTION\r
24         MB_ICONEXCLAMATION\r
25         MB_ICONASTERISK\r
26         MB_ICONWARNING\r
27         MB_ICONERROR\r
28         MB_ICONINFORMATION\r
29         MB_ICONSTOP\r
30     );\r
31     @EXPORT_OK = qw(\r
32         GetOSName\r
33         SW_HIDE\r
34         SW_SHOWNORMAL\r
35         SW_SHOWMINIMIZED\r
36         SW_SHOWMAXIMIZED\r
37         SW_SHOWNOACTIVATE\r
38 \r
39         CSIDL_DESKTOP\r
40         CSIDL_PROGRAMS\r
41         CSIDL_PERSONAL\r
42         CSIDL_FAVORITES\r
43         CSIDL_STARTUP\r
44         CSIDL_RECENT\r
45         CSIDL_SENDTO\r
46         CSIDL_STARTMENU\r
47         CSIDL_MYMUSIC\r
48         CSIDL_MYVIDEO\r
49         CSIDL_DESKTOPDIRECTORY\r
50         CSIDL_NETHOOD\r
51         CSIDL_FONTS\r
52         CSIDL_TEMPLATES\r
53         CSIDL_COMMON_STARTMENU\r
54         CSIDL_COMMON_PROGRAMS\r
55         CSIDL_COMMON_STARTUP\r
56         CSIDL_COMMON_DESKTOPDIRECTORY\r
57         CSIDL_APPDATA\r
58         CSIDL_PRINTHOOD\r
59         CSIDL_LOCAL_APPDATA\r
60         CSIDL_COMMON_FAVORITES\r
61         CSIDL_INTERNET_CACHE\r
62         CSIDL_COOKIES\r
63         CSIDL_HISTORY\r
64         CSIDL_COMMON_APPDATA\r
65         CSIDL_WINDOWS\r
66         CSIDL_SYSTEM\r
67         CSIDL_PROGRAM_FILES\r
68         CSIDL_MYPICTURES\r
69         CSIDL_PROFILE\r
70         CSIDL_PROGRAM_FILES_COMMON\r
71         CSIDL_COMMON_TEMPLATES\r
72         CSIDL_COMMON_DOCUMENTS\r
73         CSIDL_COMMON_ADMINTOOLS\r
74         CSIDL_ADMINTOOLS\r
75         CSIDL_COMMON_MUSIC\r
76         CSIDL_COMMON_PICTURES\r
77         CSIDL_COMMON_VIDEO\r
78         CSIDL_RESOURCES\r
79         CSIDL_RESOURCES_LOCALIZED\r
80         CSIDL_CDBURN_AREA\r
81     );\r
82 }\r
83 \r
84 # We won't bother with the constant stuff, too much of a hassle.  Just hard\r
85 # code it here.\r
86 \r
87 sub NULL                                { 0 }\r
88 sub WIN31_CLASS                         { &NULL }\r
89 \r
90 sub OWNER_SECURITY_INFORMATION          { 0x00000001 }\r
91 sub GROUP_SECURITY_INFORMATION          { 0x00000002 }\r
92 sub DACL_SECURITY_INFORMATION           { 0x00000004 }\r
93 sub SACL_SECURITY_INFORMATION           { 0x00000008 }\r
94 \r
95 sub MB_ICONHAND                         { 0x00000010 }\r
96 sub MB_ICONQUESTION                     { 0x00000020 }\r
97 sub MB_ICONEXCLAMATION                  { 0x00000030 }\r
98 sub MB_ICONASTERISK                     { 0x00000040 }\r
99 sub MB_ICONWARNING                      { 0x00000030 }\r
100 sub MB_ICONERROR                        { 0x00000010 }\r
101 sub MB_ICONINFORMATION                  { 0x00000040 }\r
102 sub MB_ICONSTOP                         { 0x00000010 }\r
103 \r
104 #\r
105 # Newly added constants.  These have an empty prototype, unlike the\r
106 # the ones above, which aren't prototyped for compatibility reasons.\r
107 #\r
108 sub SW_HIDE           ()                { 0 }\r
109 sub SW_SHOWNORMAL     ()                { 1 }\r
110 sub SW_SHOWMINIMIZED  ()                { 2 }\r
111 sub SW_SHOWMAXIMIZED  ()                { 3 }\r
112 sub SW_SHOWNOACTIVATE ()                { 4 }\r
113 \r
114 sub CSIDL_DESKTOP              ()       { 0x0000 }     # <desktop>\r
115 sub CSIDL_PROGRAMS             ()       { 0x0002 }     # Start Menu\Programs\r
116 sub CSIDL_PERSONAL             ()       { 0x0005 }     # "My Documents" folder\r
117 sub CSIDL_FAVORITES            ()       { 0x0006 }     # <user name>\Favorites\r
118 sub CSIDL_STARTUP              ()       { 0x0007 }     # Start Menu\Programs\Startup\r
119 sub CSIDL_RECENT               ()       { 0x0008 }     # <user name>\Recent\r
120 sub CSIDL_SENDTO               ()       { 0x0009 }     # <user name>\SendTo\r
121 sub CSIDL_STARTMENU            ()       { 0x000B }     # <user name>\Start Menu\r
122 sub CSIDL_MYMUSIC              ()       { 0x000D }     # "My Music" folder\r
123 sub CSIDL_MYVIDEO              ()       { 0x000E }     # "My Videos" folder\r
124 sub CSIDL_DESKTOPDIRECTORY     ()       { 0x0010 }     # <user name>\Desktop\r
125 sub CSIDL_NETHOOD              ()       { 0x0013 }     # <user name>\nethood\r
126 sub CSIDL_FONTS                ()       { 0x0014 }     # windows\fonts\r
127 sub CSIDL_TEMPLATES            ()       { 0x0015 }\r
128 sub CSIDL_COMMON_STARTMENU     ()       { 0x0016 }     # All Users\Start Menu\r
129 sub CSIDL_COMMON_PROGRAMS      ()       { 0x0017 }     # All Users\Start Menu\Programs\r
130 sub CSIDL_COMMON_STARTUP       ()       { 0x0018 }     # All Users\Startup\r
131 sub CSIDL_COMMON_DESKTOPDIRECTORY ()    { 0x0019 }     # All Users\Desktop\r
132 sub CSIDL_APPDATA              ()       { 0x001A }     # Application Data, new for NT4\r
133 sub CSIDL_PRINTHOOD            ()       { 0x001B }     # <user name>\PrintHood\r
134 sub CSIDL_LOCAL_APPDATA        ()       { 0x001C }     # non roaming, user\Local Settings\Application Data\r
135 sub CSIDL_COMMON_FAVORITES     ()       { 0x001F }\r
136 sub CSIDL_INTERNET_CACHE       ()       { 0x0020 }\r
137 sub CSIDL_COOKIES              ()       { 0x0021 }\r
138 sub CSIDL_HISTORY              ()       { 0x0022 }\r
139 sub CSIDL_COMMON_APPDATA       ()       { 0x0023 }     # All Users\Application Data\r
140 sub CSIDL_WINDOWS              ()       { 0x0024 }     # GetWindowsDirectory()\r
141 sub CSIDL_SYSTEM               ()       { 0x0025 }     # GetSystemDirectory()\r
142 sub CSIDL_PROGRAM_FILES        ()       { 0x0026 }     # C:\Program Files\r
143 sub CSIDL_MYPICTURES           ()       { 0x0027 }     # "My Pictures", new for Win2K\r
144 sub CSIDL_PROFILE              ()       { 0x0028 }     # USERPROFILE\r
145 sub CSIDL_PROGRAM_FILES_COMMON ()       { 0x002B }     # C:\Program Files\Common\r
146 sub CSIDL_COMMON_TEMPLATES     ()       { 0x002D }     # All Users\Templates\r
147 sub CSIDL_COMMON_DOCUMENTS     ()       { 0x002E }     # All Users\Documents\r
148 sub CSIDL_COMMON_ADMINTOOLS    ()       { 0x002F }     # All Users\Start Menu\Programs\Administrative Tools\r
149 sub CSIDL_ADMINTOOLS           ()       { 0x0030 }     # <user name>\Start Menu\Programs\Administrative Tools\r
150 sub CSIDL_COMMON_MUSIC         ()       { 0x0035 }     # All Users\My Music\r
151 sub CSIDL_COMMON_PICTURES      ()       { 0x0036 }     # All Users\My Pictures\r
152 sub CSIDL_COMMON_VIDEO         ()       { 0x0037 }     # All Users\My Video\r
153 sub CSIDL_RESOURCES            ()       { 0x0038 }     # %windir%\Resources\, For theme and other windows resources.\r
154 sub CSIDL_RESOURCES_LOCALIZED  ()       { 0x0039 }     # %windir%\Resources\<LangID>, for theme and other windows specific resources.\r
155 sub CSIDL_CDBURN_AREA          ()       { 0x003B }     # <user name>\Local Settings\Application Data\Microsoft\CD Burning\r
156 \r
157 ### This method is just a simple interface into GetOSVersion().  More\r
158 ### specific or demanding situations should use that instead.\r
159 \r
160 my ($cached_os, $cached_desc);\r
161 \r
162 sub GetOSName {\r
163     unless (defined $cached_os) {\r
164         my($desc, $major, $minor, $build, $id, undef, undef, undef, $producttype)\r
165             = Win32::GetOSVersion();\r
166         ($cached_os, $cached_desc) = _GetOSName($desc, $major, $minor, $build, $id, $producttype);\r
167     }\r
168     return wantarray ? ($cached_os, $cached_desc) : $cached_os;\r
169 }\r
170 \r
171 sub _GetOSName {\r
172     my($desc, $major, $minor, $build, $id, $producttype) = @_;\r
173 \r
174     my($os,$tag);\r
175     if ($id == 0) {\r
176         $os = "Win32s";\r
177     }\r
178     elsif ($id == 1) {\r
179         $os = { 0 => "95", 10 => "98", 90 => "Me" }->{$minor};\r
180     }\r
181     elsif ($id == 2) {\r
182         if ($major == 3) {\r
183             $os = "NT3.51";\r
184         }\r
185         elsif ($major == 4) {\r
186             $os = "NT4";\r
187         }\r
188         elsif ($major == 5) {\r
189             $os = { 0 => "2000", 1 => "XP/.Net", 2 => "2003" }->{$minor};\r
190         }\r
191         elsif ($major == 6) {\r
192             $os = { 0 => "Vista", 1 => "7" }->{$minor};\r
193             # 2008 is same as Vista but has "Domaincontroller" or "Server" type\r
194             $os = "2008" if $os eq "Vista" && $producttype != 1;\r
195         }\r
196     }\r
197 \r
198     unless (defined $os) {\r
199         warn "Unknown Windows version [$id:$major:$minor]";\r
200         return;\r
201     }\r
202 \r
203     # Take a look at the build numbers and try to deduce\r
204     # the exact release name, but we put that in the $desc\r
205     if ($os eq "95") {\r
206         $tag = { 67109814 => "(a)", 67306684 => "(b1)", "67109975" => "(b2)" }->{$build};\r
207     }\r
208     elsif ($os eq "98" && $build eq "67766446") {\r
209         $tag = "(2nd ed)";\r
210     }\r
211     if ($tag) {\r
212         $desc = length($desc) ? "$tag $desc" : $tag;\r
213     }\r
214 \r
215      return ("Win$os", $desc);\r
216 }\r
217 \r
218 # "no warnings 'redefine';" doesn't work for 5.8.7 and earlier\r
219 local $^W = 0;\r
220 bootstrap Win32;\r
221 \r
222 1;\r
223 \r
224 __END__\r
225 \r
226 =head1 NAME\r
227 \r
228 Win32 - Interfaces to some Win32 API Functions\r
229 \r
230 =head1 DESCRIPTION\r
231 \r
232 The Win32 module contains functions to access Win32 APIs.\r
233 \r
234 =head2 Alphabetical Listing of Win32 Functions\r
235 \r
236 It is recommended to C<use Win32;> before any of these functions;\r
237 however, for backwards compatibility, those marked as [CORE] will\r
238 automatically do this for you.\r
239 \r
240 In the function descriptions below the term I<Unicode string> is used\r
241 to indicate that the string may contain characters outside the system\r
242 codepage.  The caveat I<If supported by the core Perl version>\r
243 generally means Perl 5.8.9 and later, though some Unicode pathname\r
244 functionality may work on earlier versions.\r
245 \r
246 =over\r
247 \r
248 =item Win32::AbortSystemShutdown(MACHINE)\r
249 \r
250 Aborts a system shutdown (started by the\r
251 InitiateSystemShutdown function) on the specified MACHINE.\r
252 \r
253 =item Win32::BuildNumber()\r
254 \r
255 [CORE] Returns the ActivePerl build number.  This function is\r
256 only available in the ActivePerl binary distribution.\r
257 \r
258 =item Win32::CopyFile(FROM, TO, OVERWRITE)\r
259 \r
260 [CORE] The Win32::CopyFile() function copies an existing file to a new\r
261 file.  All file information like creation time and file attributes will\r
262 be copied to the new file.  However it will B<not> copy the security\r
263 information.  If the destination file already exists it will only be\r
264 overwritten when the OVERWRITE parameter is true.  But even this will\r
265 not overwrite a read-only file; you have to unlink() it first\r
266 yourself.\r
267 \r
268 =item Win32::CreateDirectory(DIRECTORY)\r
269 \r
270 Creates the DIRECTORY and returns a true value on success.  Check $^E\r
271 on failure for extended error information.\r
272 \r
273 DIRECTORY may contain Unicode characters outside the system codepage.\r
274 Once the directory has been created you can use\r
275 Win32::GetANSIPathName() to get a name that can be passed to system\r
276 calls and external programs.\r
277 \r
278 =item Win32::CreateFile(FILE)\r
279 \r
280 Creates the FILE and returns a true value on success.  Check $^E on\r
281 failure for extended error information.\r
282 \r
283 FILE may contain Unicode characters outside the system codepage.  Once\r
284 the file has been created you can use Win32::GetANSIPathName() to get\r
285 a name that can be passed to system calls and external programs.\r
286 \r
287 =item Win32::DomainName()\r
288 \r
289 [CORE] Returns the name of the Microsoft Network domain or workgroup\r
290 that the owner of the current perl process is logged into.  The\r
291 "Workstation" service must be running to determine this\r
292 information.  This function does B<not> work on Windows 9x.\r
293 \r
294 =item Win32::ExpandEnvironmentStrings(STRING)\r
295 \r
296 Takes STRING and replaces all referenced environment variable\r
297 names with their defined values.  References to environment variables\r
298 take the form C<%VariableName%>.  Case is ignored when looking up the\r
299 VariableName in the environment.  If the variable is not found then the\r
300 original C<%VariableName%> text is retained.  Has the same effect\r
301 as the following:\r
302 \r
303         $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg\r
304 \r
305 However, this function may return a Unicode string if the environment\r
306 variable being expanded hasn't been assigned to via %ENV.  Access\r
307 to %ENV is currently always using byte semantics.\r
308 \r
309 =item Win32::FormatMessage(ERRORCODE)\r
310 \r
311 [CORE] Converts the supplied Win32 error number (e.g. returned by\r
312 Win32::GetLastError()) to a descriptive string.  Analogous to the\r
313 perror() standard-C library function.  Note that C<$^E> used\r
314 in a string context has much the same effect.\r
315 \r
316         C:\> perl -e "$^E = 26; print $^E;"\r
317         The specified disk or diskette cannot be accessed\r
318 \r
319 =item Win32::FsType()\r
320 \r
321 [CORE] Returns the name of the filesystem of the currently active\r
322 drive (like 'FAT' or 'NTFS').  In list context it returns three values:\r
323 (FSTYPE, FLAGS, MAXCOMPLEN).  FSTYPE is the filesystem type as\r
324 before.  FLAGS is a combination of values of the following table:\r
325 \r
326         0x00000001  supports case-sensitive filenames\r
327         0x00000002  preserves the case of filenames\r
328         0x00000004  supports Unicode in filenames\r
329         0x00000008  preserves and enforces ACLs\r
330         0x00000010  supports file-based compression\r
331         0x00000020  supports disk quotas\r
332         0x00000040  supports sparse files\r
333         0x00000080  supports reparse points\r
334         0x00000100  supports remote storage\r
335         0x00008000  is a compressed volume (e.g. DoubleSpace)\r
336         0x00010000  supports object identifiers\r
337         0x00020000  supports the Encrypted File System (EFS)\r
338 \r
339 MAXCOMPLEN is the maximum length of a filename component (the part\r
340 between two backslashes) on this file system.\r
341 \r
342 =item Win32::FreeLibrary(HANDLE)\r
343 \r
344 Unloads a previously loaded dynamic-link library.  The HANDLE is\r
345 no longer valid after this call.  See L<LoadLibrary|Win32::LoadLibrary(LIBNAME)>\r
346 for information on dynamically loading a library.\r
347 \r
348 =item Win32::GetANSIPathName(FILENAME)\r
349 \r
350 Returns an ANSI version of FILENAME.  This may be the short name\r
351 if the long name cannot be represented in the system codepage.\r
352 \r
353 While not currently implemented, it is possible that in the future\r
354 this function will convert only parts of the path to FILENAME to a\r
355 short form.\r
356 \r
357 If FILENAME doesn't exist on the filesystem, or if the filesystem\r
358 doesn't support short ANSI filenames, then this function will\r
359 translate the Unicode name into the system codepage using replacement\r
360 characters.\r
361 \r
362 =item Win32::GetArchName()\r
363 \r
364 Use of this function is deprecated.  It is equivalent with\r
365 $ENV{PROCESSOR_ARCHITECTURE}.  This might not work on Win9X.\r
366 \r
367 =item Win32::GetChipName()\r
368 \r
369 Returns the processor type: 386, 486 or 586 for Intel processors,\r
370 21064 for the Alpha chip.\r
371 \r
372 =item Win32::GetCwd()\r
373 \r
374 [CORE] Returns the current active drive and directory.  This function\r
375 does not return a UNC path, since the functionality required for such\r
376 a feature is not available under Windows 95.\r
377 \r
378 If supported by the core Perl version, this function will return an\r
379 ANSI path name for the current directory if the long pathname cannot\r
380 be represented in the system codepage.\r
381 \r
382 =item Win32::GetCurrentProcessId()\r
383 \r
384 Returns the process identifier of the current process.  Until the\r
385 process terminates, the process identifier uniquely identifies the\r
386 process throughout the system.\r
387 \r
388 The current process identifier is normally also available via the\r
389 predefined $$ variable.  Under fork() emulation however $$ may contain\r
390 a pseudo-process identifier that is only meaningful to the Perl\r
391 kill(), wait() and waitpid() functions.  The\r
392 Win32::GetCurrentProcessId() function will always return the regular\r
393 Windows process id, even when called from inside a pseudo-process.\r
394 \r
395 =item Win32::GetCurrentThreadId()\r
396 \r
397 Returns the thread identifier of the calling thread.  Until the thread\r
398 terminates, the thread identifier uniquely identifies the thread\r
399 throughout the system.\r
400 \r
401 =item Win32::GetFileVersion(FILENAME)\r
402 \r
403 Returns the file version number from the VERSIONINFO resource of\r
404 the executable file or DLL.  This is a tuple of four 16 bit numbers.\r
405 In list context these four numbers will be returned.  In scalar context\r
406 they are concatenated into a string, separated by dots.\r
407 \r
408 =item Win32::GetFolderPath(FOLDER [, CREATE])\r
409 \r
410 Returns the full pathname of one of the Windows special folders.\r
411 The folder will be created if it doesn't exist and the optional CREATE\r
412 argument is true.  The following FOLDER constants are defined by the\r
413 Win32 module, but only exported on demand:\r
414 \r
415         CSIDL_ADMINTOOLS\r
416         CSIDL_APPDATA\r
417         CSIDL_CDBURN_AREA\r
418         CSIDL_COMMON_ADMINTOOLS\r
419         CSIDL_COMMON_APPDATA\r
420         CSIDL_COMMON_DESKTOPDIRECTORY\r
421         CSIDL_COMMON_DOCUMENTS\r
422         CSIDL_COMMON_FAVORITES\r
423         CSIDL_COMMON_MUSIC\r
424         CSIDL_COMMON_PICTURES\r
425         CSIDL_COMMON_PROGRAMS\r
426         CSIDL_COMMON_STARTMENU\r
427         CSIDL_COMMON_STARTUP\r
428         CSIDL_COMMON_TEMPLATES\r
429         CSIDL_COMMON_VIDEO\r
430         CSIDL_COOKIES\r
431         CSIDL_DESKTOP\r
432         CSIDL_DESKTOPDIRECTORY\r
433         CSIDL_FAVORITES\r
434         CSIDL_FONTS\r
435         CSIDL_HISTORY\r
436         CSIDL_INTERNET_CACHE\r
437         CSIDL_LOCAL_APPDATA\r
438         CSIDL_MYMUSIC\r
439         CSIDL_MYPICTURES\r
440         CSIDL_MYVIDEO\r
441         CSIDL_NETHOOD\r
442         CSIDL_PERSONAL\r
443         CSIDL_PRINTHOOD\r
444         CSIDL_PROFILE\r
445         CSIDL_PROGRAMS\r
446         CSIDL_PROGRAM_FILES\r
447         CSIDL_PROGRAM_FILES_COMMON\r
448         CSIDL_RECENT\r
449         CSIDL_RESOURCES\r
450         CSIDL_RESOURCES_LOCALIZED\r
451         CSIDL_SENDTO\r
452         CSIDL_STARTMENU\r
453         CSIDL_STARTUP\r
454         CSIDL_SYSTEM\r
455         CSIDL_TEMPLATES\r
456         CSIDL_WINDOWS\r
457 \r
458 Note that not all folders are defined on all versions of Windows.\r
459 \r
460 Please refer to the MSDN documentation of the CSIDL constants,\r
461 currently available at:\r
462 \r
463 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp\r
464 \r
465 This function will return an ANSI folder path if the long name cannot\r
466 be represented in the system codepage.  Use Win32::GetLongPathName()\r
467 on the result of Win32::GetFolderPath() if you want the Unicode\r
468 version of the folder name.\r
469 \r
470 =item Win32::GetFullPathName(FILENAME)\r
471 \r
472 [CORE] GetFullPathName combines the FILENAME with the current drive\r
473 and directory name and returns a fully qualified (aka, absolute)\r
474 path name.  In list context it returns two elements: (PATH, FILE) where\r
475 PATH is the complete pathname component (including trailing backslash)\r
476 and FILE is just the filename part.  Note that no attempt is made to\r
477 convert 8.3 components in the supplied FILENAME to longnames or\r
478 vice-versa.  Compare with Win32::GetShortPathName() and\r
479 Win32::GetLongPathName().\r
480 \r
481 If supported by the core Perl version, this function will return an\r
482 ANSI path name if the full pathname cannot be represented in the\r
483 system codepage.\r
484 \r
485 =item Win32::GetLastError()\r
486 \r
487 [CORE] Returns the last error value generated by a call to a Win32 API\r
488 function.  Note that C<$^E> used in a numeric context amounts to the\r
489 same value.\r
490 \r
491 =item Win32::GetLongPathName(PATHNAME)\r
492 \r
493 [CORE] Returns a representation of PATHNAME composed of longname\r
494 components (if any).  The result may not necessarily be longer\r
495 than PATHNAME.  No attempt is made to convert PATHNAME to the\r
496 absolute path.  Compare with Win32::GetShortPathName() and\r
497 Win32::GetFullPathName().\r
498 \r
499 This function may return the pathname in Unicode if it cannot be\r
500 represented in the system codepage.  Use Win32::GetANSIPathName()\r
501 before passing the path to a system call or another program.\r
502 \r
503 =item Win32::GetNextAvailDrive()\r
504 \r
505 [CORE] Returns a string in the form of "<d>:" where <d> is the first\r
506 available drive letter.\r
507 \r
508 =item Win32::GetOSVersion()\r
509 \r
510 [CORE] Returns the list (STRING, MAJOR, MINOR, BUILD, ID), where the\r
511 elements are, respectively: An arbitrary descriptive string, the major\r
512 version number of the operating system, the minor version number, the\r
513 build number, and a digit indicating the actual operating system.\r
514 For the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for\r
515 Windows NT/2000/XP/2003/Vista/2008/7.  In scalar context it returns just\r
516 the ID.\r
517 \r
518 Currently known values for ID MAJOR and MINOR are as follows:\r
519 \r
520     OS                    ID    MAJOR   MINOR\r
521     Win32s                 0      -       -\r
522     Windows 95             1      4       0\r
523     Windows 98             1      4      10\r
524     Windows Me             1      4      90\r
525     Windows NT 3.51        2      3      51\r
526     Windows NT 4           2      4       0\r
527     Windows 2000           2      5       0\r
528     Windows XP             2      5       1\r
529     Windows Server 2003    2      5       2\r
530     Windows Vista          2      6       0\r
531     Windows Server 2008    2      6       0\r
532     Windows 7              2      6       1\r
533 \r
534 On Windows NT 4 SP6 and later this function returns the following\r
535 additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.\r
536 \r
537 The version numbers for Windows Vista and Windows Server 2008 are\r
538 identical; the PRODUCTTYPE field must be used to differentiate\r
539 between them.\r
540 \r
541 SPMAJOR and SPMINOR are are the version numbers of the latest\r
542 installed service pack.\r
543 \r
544 SUITEMASK is a bitfield identifying the product suites available on\r
545 the system.  Known bits are:\r
546 \r
547     VER_SUITE_SMALLBUSINESS             0x00000001\r
548     VER_SUITE_ENTERPRISE                0x00000002\r
549     VER_SUITE_BACKOFFICE                0x00000004\r
550     VER_SUITE_COMMUNICATIONS            0x00000008\r
551     VER_SUITE_TERMINAL                  0x00000010\r
552     VER_SUITE_SMALLBUSINESS_RESTRICTED  0x00000020\r
553     VER_SUITE_EMBEDDEDNT                0x00000040\r
554     VER_SUITE_DATACENTER                0x00000080\r
555     VER_SUITE_SINGLEUSERTS              0x00000100\r
556     VER_SUITE_PERSONAL                  0x00000200\r
557     VER_SUITE_BLADE                     0x00000400\r
558     VER_SUITE_EMBEDDED_RESTRICTED       0x00000800\r
559     VER_SUITE_SECURITY_APPLIANCE        0x00001000\r
560 \r
561 The VER_SUITE_xxx names are listed here to crossreference the Microsoft\r
562 documentation.  The Win32 module does not provide symbolic names for these\r
563 constants.\r
564 \r
565 PRODUCTTYPE provides additional information about the system.  It should\r
566 be one of the following integer values:\r
567 \r
568     1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro, Vista)\r
569     2 - Domaincontroller\r
570     3 - Server (2000 Server, Server 2003, Server 2008)\r
571 \r
572 Note that a server that is also a domain controller is reported as\r
573 PRODUCTTYPE 2 (Domaincontroller) and not PRODUCTTYPE 3 (Server).\r
574 \r
575 =item Win32::GetOSName()\r
576 \r
577 In scalar context returns the name of the Win32 operating system\r
578 being used.  In list context returns a two element list of the OS name\r
579 and whatever edition information is known about the particular build\r
580 (for Win9X boxes) and whatever service packs have been installed.\r
581 The latter is roughly equivalent to the first item returned by\r
582 GetOSVersion() in list context.\r
583 \r
584 Currently the possible values for the OS name are\r
585 \r
586     WinWin32s\r
587     Win95\r
588     Win98\r
589     WinMe\r
590     WinNT3.51\r
591     WinNT4\r
592     Win2000\r
593     WinXP/.Net\r
594     Win2003\r
595     WinVista\r
596     Win2008\r
597     Win7\r
598 \r
599 This routine is just a simple interface into GetOSVersion().  More\r
600 specific or demanding situations should use that instead.  Another\r
601 option would be to use POSIX::uname(), however the latter appears to\r
602 report only the OS family name and not the specific OS.  In scalar\r
603 context it returns just the ID.\r
604 \r
605 The name "WinXP/.Net" is used for historical reasons only, to maintain\r
606 backwards compatibility of the Win32 module.  Windows .NET Server has\r
607 been renamed as Windows 2003 Server before final release and uses a\r
608 different major/minor version number than Windows XP.\r
609 \r
610 Similarly the name "WinWin32s" should have been "Win32s" but has been\r
611 kept as-is for backwards compatibility reasons too.\r
612 \r
613 =item Win32::GetShortPathName(PATHNAME)\r
614 \r
615 [CORE] Returns a representation of PATHNAME that is composed of short\r
616 (8.3) path components where available.  For path components where the\r
617 file system has not generated the short form the returned path will\r
618 use the long form, so this function might still for instance return a\r
619 path containing spaces.  Returns C<undef> when the PATHNAME does not\r
620 exist. Compare with Win32::GetFullPathName() and\r
621 Win32::GetLongPathName().\r
622 \r
623 =item Win32::GetProcAddress(INSTANCE, PROCNAME)\r
624 \r
625 Returns the address of a function inside a loaded library.  The\r
626 information about what you can do with this address has been lost in\r
627 the mist of time.  Use the Win32::API module instead of this deprecated\r
628 function.\r
629 \r
630 =item Win32::GetTickCount()\r
631 \r
632 [CORE] Returns the number of milliseconds elapsed since the last\r
633 system boot.  Resolution is limited to system timer ticks (about 10ms\r
634 on WinNT and 55ms on Win9X).\r
635 \r
636 =item Win32::GuidGen()\r
637 \r
638 Creates a globally unique 128 bit integer that can be used as a\r
639 persistent identifier in a distributed setting. To a very high degree\r
640 of certainty this function returns a unique value. No other\r
641 invocation, on the same or any other system (networked or not), should\r
642 return the same value.\r
643 \r
644 The return value is formatted according to OLE conventions, as groups\r
645 of hex digits with surrounding braces.  For example:\r
646 \r
647     {09531CF1-D0C7-4860-840C-1C8C8735E2AD}\r
648  \r
649 =item Win32::InitiateSystemShutdown\r
650 \r
651 (MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)\r
652 \r
653 Shutsdown the specified MACHINE, notifying users with the\r
654 supplied MESSAGE, within the specified TIMEOUT interval.  Forces\r
655 closing of all documents without prompting the user if FORCECLOSE is\r
656 true, and reboots the machine if REBOOT is true.  This function works\r
657 only on WinNT.\r
658 \r
659 =item Win32::IsAdminUser()\r
660 \r
661 Returns non zero if the account in whose security context the\r
662 current process/thread is running belongs to the local group of\r
663 Administrators in the built-in system domain; returns 0 if not.\r
664 On Windows Vista it will only return non-zero if the process is\r
665 actually running with elevated privileges.  Returns C<undef>\r
666 and prints a warning if an error occurred.  This function always\r
667 returns 1 on Win9X.\r
668 \r
669 =item Win32::IsWinNT()\r
670 \r
671 [CORE] Returns non zero if the Win32 subsystem is Windows NT.\r
672 \r
673 =item Win32::IsWin95()\r
674 \r
675 [CORE] Returns non zero if the Win32 subsystem is Windows 95.\r
676 \r
677 =item Win32::LoadLibrary(LIBNAME)\r
678 \r
679 Loads a dynamic link library into memory and returns its module\r
680 handle.  This handle can be used with Win32::GetProcAddress() and\r
681 Win32::FreeLibrary().  This function is deprecated.  Use the Win32::API\r
682 module instead.\r
683 \r
684 =item Win32::LoginName()\r
685 \r
686 [CORE] Returns the username of the owner of the current perl process.\r
687 The return value may be a Unicode string.\r
688 \r
689 =item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE)\r
690 \r
691 Looks up ACCOUNT on SYSTEM and returns the domain name the SID and\r
692 the SID type.\r
693 \r
694 =item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE)\r
695 \r
696 Looks up SID on SYSTEM and returns the account name, domain name,\r
697 and the SID type.\r
698 \r
699 =item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])\r
700 \r
701 Create a dialogbox containing MESSAGE.  FLAGS specifies the\r
702 required icon and buttons according to the following table:\r
703 \r
704         0 = OK\r
705         1 = OK and Cancel\r
706         2 = Abort, Retry, and Ignore\r
707         3 = Yes, No and Cancel\r
708         4 = Yes and No\r
709         5 = Retry and Cancel\r
710 \r
711         MB_ICONSTOP          "X" in a red circle\r
712         MB_ICONQUESTION      question mark in a bubble\r
713         MB_ICONEXCLAMATION   exclamation mark in a yellow triangle\r
714         MB_ICONINFORMATION   "i" in a bubble\r
715 \r
716 TITLE specifies an optional window title.  The default is "Perl".\r
717 \r
718 The function returns the menu id of the selected push button:\r
719 \r
720         0  Error\r
721 \r
722         1  OK\r
723         2  Cancel\r
724         3  Abort\r
725         4  Retry\r
726         5  Ignore\r
727         6  Yes\r
728         7  No\r
729 \r
730 =item Win32::NodeName()\r
731 \r
732 [CORE] Returns the Microsoft Network node-name of the current machine.\r
733 \r
734 =item Win32::OutputDebugString(STRING)\r
735 \r
736 Sends a string to the application or system debugger for display.\r
737 The function does nothing if there is no active debugger.\r
738 \r
739 Alternatively one can use the I<Debug Viewer> application to\r
740 watch the OutputDebugString() output:\r
741 \r
742 http://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx\r
743 \r
744 =item Win32::RegisterServer(LIBRARYNAME)\r
745 \r
746 Loads the DLL LIBRARYNAME and calls the function DllRegisterServer.\r
747 \r
748 =item Win32::SetChildShowWindow(SHOWWINDOW)\r
749 \r
750 [CORE] Sets the I<ShowMode> of child processes started by system().\r
751 By default system() will create a new console window for child\r
752 processes if Perl itself is not running from a console.  Calling\r
753 SetChildShowWindow(0) will make these new console windows invisible.\r
754 Calling SetChildShowWindow() without arguments reverts system() to the\r
755 default behavior.  The return value of SetChildShowWindow() is the\r
756 previous setting or C<undef>.\r
757 \r
758 The following symbolic constants for SHOWWINDOW are available\r
759 (but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL,\r
760 SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE.\r
761 \r
762 =item Win32::SetCwd(NEWDIRECTORY)\r
763 \r
764 [CORE] Sets the current active drive and directory.  This function does not\r
765 work with UNC paths, since the functionality required to required for\r
766 such a feature is not available under Windows 95.\r
767 \r
768 =item Win32::SetLastError(ERROR)\r
769 \r
770 [CORE] Sets the value of the last error encountered to ERROR.  This is\r
771 that value that will be returned by the Win32::GetLastError()\r
772 function.\r
773 \r
774 =item Win32::Sleep(TIME)\r
775 \r
776 [CORE] Pauses for TIME milliseconds.  The timeslices are made available\r
777 to other processes and threads.\r
778 \r
779 =item Win32::Spawn(COMMAND, ARGS, PID)\r
780 \r
781 [CORE] Spawns a new process using the supplied COMMAND, passing in\r
782 arguments in the string ARGS.  The pid of the new process is stored in\r
783 PID.  This function is deprecated.  Please use the Win32::Process module\r
784 instead.\r
785 \r
786 =item Win32::UnregisterServer(LIBRARYNAME)\r
787 \r
788 Loads the DLL LIBRARYNAME and calls the function\r
789 DllUnregisterServer.\r
790 \r
791 =back\r
792 \r
793 =cut\r