This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/locale.t: White-space only
[perl5.git] / cpan / Win32 / Win32.pm
1 package Win32;
2
3 # BEGIN {
4     use strict;
5     use vars qw|$VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK|;
6
7     require Exporter;
8     require DynaLoader;
9
10     @ISA = qw|Exporter DynaLoader|;
11     $VERSION = '0.47';
12     $XS_VERSION = $VERSION;
13     $VERSION = eval $VERSION;
14
15     @EXPORT = qw(
16         NULL
17         WIN31_CLASS
18         OWNER_SECURITY_INFORMATION
19         GROUP_SECURITY_INFORMATION
20         DACL_SECURITY_INFORMATION
21         SACL_SECURITY_INFORMATION
22         MB_ICONHAND
23         MB_ICONQUESTION
24         MB_ICONEXCLAMATION
25         MB_ICONASTERISK
26         MB_ICONWARNING
27         MB_ICONERROR
28         MB_ICONINFORMATION
29         MB_ICONSTOP
30     );
31     @EXPORT_OK = qw(
32         GetOSName
33         SW_HIDE
34         SW_SHOWNORMAL
35         SW_SHOWMINIMIZED
36         SW_SHOWMAXIMIZED
37         SW_SHOWNOACTIVATE
38
39         CSIDL_DESKTOP
40         CSIDL_PROGRAMS
41         CSIDL_PERSONAL
42         CSIDL_FAVORITES
43         CSIDL_STARTUP
44         CSIDL_RECENT
45         CSIDL_SENDTO
46         CSIDL_STARTMENU
47         CSIDL_MYMUSIC
48         CSIDL_MYVIDEO
49         CSIDL_DESKTOPDIRECTORY
50         CSIDL_NETHOOD
51         CSIDL_FONTS
52         CSIDL_TEMPLATES
53         CSIDL_COMMON_STARTMENU
54         CSIDL_COMMON_PROGRAMS
55         CSIDL_COMMON_STARTUP
56         CSIDL_COMMON_DESKTOPDIRECTORY
57         CSIDL_APPDATA
58         CSIDL_PRINTHOOD
59         CSIDL_LOCAL_APPDATA
60         CSIDL_COMMON_FAVORITES
61         CSIDL_INTERNET_CACHE
62         CSIDL_COOKIES
63         CSIDL_HISTORY
64         CSIDL_COMMON_APPDATA
65         CSIDL_WINDOWS
66         CSIDL_SYSTEM
67         CSIDL_PROGRAM_FILES
68         CSIDL_MYPICTURES
69         CSIDL_PROFILE
70         CSIDL_PROGRAM_FILES_COMMON
71         CSIDL_COMMON_TEMPLATES
72         CSIDL_COMMON_DOCUMENTS
73         CSIDL_COMMON_ADMINTOOLS
74         CSIDL_ADMINTOOLS
75         CSIDL_COMMON_MUSIC
76         CSIDL_COMMON_PICTURES
77         CSIDL_COMMON_VIDEO
78         CSIDL_RESOURCES
79         CSIDL_RESOURCES_LOCALIZED
80         CSIDL_CDBURN_AREA
81     );
82 # }
83
84 # We won't bother with the constant stuff, too much of a hassle.  Just hard
85 # code it here.
86
87 sub NULL                                { 0 }
88 sub WIN31_CLASS                         { &NULL }
89
90 sub OWNER_SECURITY_INFORMATION          { 0x00000001 }
91 sub GROUP_SECURITY_INFORMATION          { 0x00000002 }
92 sub DACL_SECURITY_INFORMATION           { 0x00000004 }
93 sub SACL_SECURITY_INFORMATION           { 0x00000008 }
94
95 sub MB_ICONHAND                         { 0x00000010 }
96 sub MB_ICONQUESTION                     { 0x00000020 }
97 sub MB_ICONEXCLAMATION                  { 0x00000030 }
98 sub MB_ICONASTERISK                     { 0x00000040 }
99 sub MB_ICONWARNING                      { 0x00000030 }
100 sub MB_ICONERROR                        { 0x00000010 }
101 sub MB_ICONINFORMATION                  { 0x00000040 }
102 sub MB_ICONSTOP                         { 0x00000010 }
103
104 #
105 # Newly added constants.  These have an empty prototype, unlike the
106 # the ones above, which aren't prototyped for compatibility reasons.
107 #
108 sub SW_HIDE           ()                { 0 }
109 sub SW_SHOWNORMAL     ()                { 1 }
110 sub SW_SHOWMINIMIZED  ()                { 2 }
111 sub SW_SHOWMAXIMIZED  ()                { 3 }
112 sub SW_SHOWNOACTIVATE ()                { 4 }
113
114 sub CSIDL_DESKTOP              ()       { 0x0000 }     # <desktop>
115 sub CSIDL_PROGRAMS             ()       { 0x0002 }     # Start Menu\Programs
116 sub CSIDL_PERSONAL             ()       { 0x0005 }     # "My Documents" folder
117 sub CSIDL_FAVORITES            ()       { 0x0006 }     # <user name>\Favorites
118 sub CSIDL_STARTUP              ()       { 0x0007 }     # Start Menu\Programs\Startup
119 sub CSIDL_RECENT               ()       { 0x0008 }     # <user name>\Recent
120 sub CSIDL_SENDTO               ()       { 0x0009 }     # <user name>\SendTo
121 sub CSIDL_STARTMENU            ()       { 0x000B }     # <user name>\Start Menu
122 sub CSIDL_MYMUSIC              ()       { 0x000D }     # "My Music" folder
123 sub CSIDL_MYVIDEO              ()       { 0x000E }     # "My Videos" folder
124 sub CSIDL_DESKTOPDIRECTORY     ()       { 0x0010 }     # <user name>\Desktop
125 sub CSIDL_NETHOOD              ()       { 0x0013 }     # <user name>\nethood
126 sub CSIDL_FONTS                ()       { 0x0014 }     # windows\fonts
127 sub CSIDL_TEMPLATES            ()       { 0x0015 }
128 sub CSIDL_COMMON_STARTMENU     ()       { 0x0016 }     # All Users\Start Menu
129 sub CSIDL_COMMON_PROGRAMS      ()       { 0x0017 }     # All Users\Start Menu\Programs
130 sub CSIDL_COMMON_STARTUP       ()       { 0x0018 }     # All Users\Startup
131 sub CSIDL_COMMON_DESKTOPDIRECTORY ()    { 0x0019 }     # All Users\Desktop
132 sub CSIDL_APPDATA              ()       { 0x001A }     # Application Data, new for NT4
133 sub CSIDL_PRINTHOOD            ()       { 0x001B }     # <user name>\PrintHood
134 sub CSIDL_LOCAL_APPDATA        ()       { 0x001C }     # non roaming, user\Local Settings\Application Data
135 sub CSIDL_COMMON_FAVORITES     ()       { 0x001F }
136 sub CSIDL_INTERNET_CACHE       ()       { 0x0020 }
137 sub CSIDL_COOKIES              ()       { 0x0021 }
138 sub CSIDL_HISTORY              ()       { 0x0022 }
139 sub CSIDL_COMMON_APPDATA       ()       { 0x0023 }     # All Users\Application Data
140 sub CSIDL_WINDOWS              ()       { 0x0024 }     # GetWindowsDirectory()
141 sub CSIDL_SYSTEM               ()       { 0x0025 }     # GetSystemDirectory()
142 sub CSIDL_PROGRAM_FILES        ()       { 0x0026 }     # C:\Program Files
143 sub CSIDL_MYPICTURES           ()       { 0x0027 }     # "My Pictures", new for Win2K
144 sub CSIDL_PROFILE              ()       { 0x0028 }     # USERPROFILE
145 sub CSIDL_PROGRAM_FILES_COMMON ()       { 0x002B }     # C:\Program Files\Common
146 sub CSIDL_COMMON_TEMPLATES     ()       { 0x002D }     # All Users\Templates
147 sub CSIDL_COMMON_DOCUMENTS     ()       { 0x002E }     # All Users\Documents
148 sub CSIDL_COMMON_ADMINTOOLS    ()       { 0x002F }     # All Users\Start Menu\Programs\Administrative Tools
149 sub CSIDL_ADMINTOOLS           ()       { 0x0030 }     # <user name>\Start Menu\Programs\Administrative Tools
150 sub CSIDL_COMMON_MUSIC         ()       { 0x0035 }     # All Users\My Music
151 sub CSIDL_COMMON_PICTURES      ()       { 0x0036 }     # All Users\My Pictures
152 sub CSIDL_COMMON_VIDEO         ()       { 0x0037 }     # All Users\My Video
153 sub CSIDL_RESOURCES            ()       { 0x0038 }     # %windir%\Resources\, For theme and other windows resources.
154 sub CSIDL_RESOURCES_LOCALIZED  ()       { 0x0039 }     # %windir%\Resources\<LangID>, for theme and other windows specific resources.
155 sub CSIDL_CDBURN_AREA          ()       { 0x003B }     # <user name>\Local Settings\Application Data\Microsoft\CD Burning
156
157 sub VER_NT_DOMAIN_CONTROLLER () { 0x0000002 } # The system is a domain controller and the operating system is Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
158 sub VER_NT_SERVER () { 0x0000003 } # The operating system is Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
159 # Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER.
160 sub VER_NT_WORKSTATION () { 0x0000001 } # The operating system is Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional.
161
162
163 sub VER_SUITE_BACKOFFICE               () { 0x00000004 } # Microsoft BackOffice components are installed.
164 sub VER_SUITE_BLADE                    () { 0x00000400 } # Windows Server 2003, Web Edition is installed.
165 sub VER_SUITE_COMPUTE_SERVER           () { 0x00004000 } # Windows Server 2003, Compute Cluster Edition is installed.
166 sub VER_SUITE_DATACENTER               () { 0x00000080 } # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed.
167 sub VER_SUITE_ENTERPRISE               () { 0x00000002 } # Windows Server 2008 Enterprise, Windows Server 2003, Enterprise Edition, or Windows 2000 Advanced Server is installed. Refer to the Remarks section for more information about this bit flag.
168 sub VER_SUITE_EMBEDDEDNT               () { 0x00000040 } # Windows XP Embedded is installed.
169 sub VER_SUITE_PERSONAL                 () { 0x00000200 } # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed.
170 sub VER_SUITE_SINGLEUSERTS             () { 0x00000100 } # Remote Desktop is supported, but only one interactive session is supported. This value is set unless the system is running in application server mode.
171 sub VER_SUITE_SMALLBUSINESS            () { 0x00000001 } # Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. Refer to the Remarks section for more information about this bit flag.
172 sub VER_SUITE_SMALLBUSINESS_RESTRICTED () { 0x00000020 } # Microsoft Small Business Server is installed with the restrictive client license in force. Refer to the Remarks section for more information about this bit flag.
173 sub VER_SUITE_STORAGE_SERVER           () { 0x00002000 } # Windows Storage Server 2003 R2 or Windows Storage Server 2003 is installed.
174 sub VER_SUITE_TERMINAL                 () { 0x00000010 } # Terminal Services is installed. This value is always set.
175 # If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode.
176 sub VER_SUITE_WH_SERVER                () { 0x00008000 } # Windows Home Server is installed.
177
178
179 sub SM_TABLETPC                ()       { 86 }
180 sub SM_MEDIACENTER             ()       { 87 }
181 sub SM_STARTER                 ()       { 88 }
182 sub SM_SERVERR2                ()       { 89 }
183
184 sub PRODUCT_UNDEFINED                        () { 0x000 } # An unknown product
185 sub PRODUCT_ULTIMATE                         () { 0x001 } # Ultimate
186 sub PRODUCT_HOME_BASIC                       () { 0x002 } # Home Basic
187 sub PRODUCT_HOME_PREMIUM                     () { 0x003 } # Home Premium
188 sub PRODUCT_ENTERPRISE                       () { 0x004 } # Enterprise
189 sub PRODUCT_HOME_BASIC_N                     () { 0x005 } # Home Basic N
190 sub PRODUCT_BUSINESS                         () { 0x006 } # Business
191 sub PRODUCT_STANDARD_SERVER                  () { 0x007 } # Server Standard (full installation)
192 sub PRODUCT_DATACENTER_SERVER                () { 0x008 } # Server Datacenter (full installation)
193 sub PRODUCT_SMALLBUSINESS_SERVER             () { 0x009 } # Windows Small Business Server
194 sub PRODUCT_ENTERPRISE_SERVER                () { 0x00A } # Server Enterprise (full installation)
195 sub PRODUCT_STARTER                          () { 0x00B } # Starter
196 sub PRODUCT_DATACENTER_SERVER_CORE           () { 0x00C } # Server Datacenter (core installation)
197 sub PRODUCT_STANDARD_SERVER_CORE             () { 0x00D } # Server Standard (core installation)
198 sub PRODUCT_ENTERPRISE_SERVER_CORE           () { 0x00E } # Server Enterprise (core installation)
199 sub PRODUCT_ENTERPRISE_SERVER_IA64           () { 0x00F } # Server Enterprise for Itanium-based Systems
200 sub PRODUCT_BUSINESS_N                       () { 0x010 } # Business N
201 sub PRODUCT_WEB_SERVER                       () { 0x011 } # Web Server (full installation)
202 sub PRODUCT_CLUSTER_SERVER                   () { 0x012 } # HPC Edition
203 sub PRODUCT_HOME_SERVER                      () { 0x013 } # Home Server Edition
204 sub PRODUCT_STORAGE_EXPRESS_SERVER           () { 0x014 } # Storage Server Express
205 sub PRODUCT_STORAGE_STANDARD_SERVER          () { 0x015 } # Storage Server Standard
206 sub PRODUCT_STORAGE_WORKGROUP_SERVER         () { 0x016 } # Storage Server Workgroup
207 sub PRODUCT_STORAGE_ENTERPRISE_SERVER        () { 0x017 } # Storage Server Enterprise
208 sub PRODUCT_SERVER_FOR_SMALLBUSINESS         () { 0x018 } # Windows Server 2008 for Windows Essential Server Solutions
209 sub PRODUCT_SMALLBUSINESS_SERVER_PREMIUM     () { 0x019 } # Windows Small Business Server Premium
210 sub PRODUCT_HOME_PREMIUM_N                   () { 0x01A } # Home Premium N
211 sub PRODUCT_ENTERPRISE_N                     () { 0x01B } # Enterprise N
212 sub PRODUCT_ULTIMATE_N                       () { 0x01C } # Ultimate N
213 sub PRODUCT_WEB_SERVER_CORE                  () { 0x01D } # Web Server (core installation)
214 sub PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT () { 0x01E } # Windows Essential Business Server Management Server
215 sub PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY   () { 0x01F } # Windows Essential Business Server Security Server
216 sub PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING  () { 0x020 } # Windows Essential Business Server Messaging Server
217 sub PRODUCT_SERVER_FOUNDATION                () { 0x021 } # Server Foundation
218
219 sub PRODUCT_SERVER_FOR_SMALLBUSINESS_V       () { 0x023 } # Windows Server 2008 without Hyper-V for Windows Essential Server Solutions
220 sub PRODUCT_STANDARD_SERVER_V                () { 0x024 } # Server Standard without Hyper-V (full installation)
221 sub PRODUCT_DATACENTER_SERVER_V              () { 0x025 } # Server Datacenter without Hyper-V (full installation)
222 sub PRODUCT_ENTERPRISE_SERVER_V              () { 0x026 } # Server Enterprise without Hyper-V (full installation)
223 sub PRODUCT_DATACENTER_SERVER_CORE_V         () { 0x027 } # Server Datacenter without Hyper-V (core installation)
224 sub PRODUCT_STANDARD_SERVER_CORE_V           () { 0x028 } # Server Standard without Hyper-V (core installation)
225 sub PRODUCT_ENTERPRISE_SERVER_CORE_V         () { 0x029 } # Server Enterprise without Hyper-V (core installation)
226 sub PRODUCT_HYPERV                           () { 0x02A } # Microsoft Hyper-V Server
227
228 sub PRODUCT_STARTER_N                        () { 0x02F } # Starter N
229 sub PRODUCT_PROFESSIONAL                     () { 0x030 } # Professional
230 sub PRODUCT_PROFESSIONAL_N                   () { 0x031 } # Professional N
231
232 sub PRODUCT_STARTER_E                        () { 0x042 } # Starter E
233 sub PRODUCT_HOME_BASIC_E                     () { 0x043 } # Home Basic E
234 sub PRODUCT_HOME_PREMIUM_E                   () { 0x044 } # Home Premium E
235 sub PRODUCT_PROFESSIONAL_E                   () { 0x045 } # Professional E
236 sub PRODUCT_ENTERPRISE_E                     () { 0x046 } # Enterprise E
237 sub PRODUCT_ULTIMATE_E                       () { 0x047 } # Ultimate E
238
239 sub PRODUCT_UNLICENSED                       () { 0xABCDABCD } # product has not been activated and is no longer in the grace period
240
241 sub PROCESSOR_ARCHITECTURE_AMD64   ()   { 9 }      # x64 (AMD or Intel)
242 sub PROCESSOR_ARCHITECTURE_IA64    ()   { 6 }      # Intel Itanium Processor Family (IPF)
243 sub PROCESSOR_ARCHITECTURE_INTEL   ()   { 0 }      # x86
244 sub PROCESSOR_ARCHITECTURE_UNKNOWN ()   { 0xffff } # Unknown architecture.
245
246 sub _GetProcessorArchitecture {
247     my $arch = {
248          386 => PROCESSOR_ARCHITECTURE_INTEL,
249          486 => PROCESSOR_ARCHITECTURE_INTEL,
250          586 => PROCESSOR_ARCHITECTURE_INTEL,
251         2200 => PROCESSOR_ARCHITECTURE_IA64,
252         8664 => PROCESSOR_ARCHITECTURE_AMD64,
253     }->{Win32::GetChipName()};
254     return defined($arch) ? $arch : PROCESSOR_ARCHITECTURE_UNKNOWN;
255 }
256
257 ### This method is just a simple interface into GetOSVersion().  More
258 ### specific or demanding situations should use that instead.
259
260 my ($cached_os, $cached_desc);
261
262 sub GetOSName {
263     unless (defined $cached_os) {
264         my($desc, $major, $minor, $build, $id, undef, undef, $suitemask, $producttype)
265             = Win32::GetOSVersion();
266         my $arch = _GetProcessorArchitecture();
267         my $productinfo = Win32::GetProductInfo(6, 0, 0, 0);
268         ($cached_os, $cached_desc) = _GetOSName($desc, $major, $minor, $build, $id,
269                                                 $suitemask, $producttype, $productinfo, $arch);
270     }
271     return wantarray ? ($cached_os, $cached_desc) : $cached_os;
272 }
273
274 sub GetOSDisplayName {
275     # Calling GetOSDisplayName() with arguments is for the test suite only!
276     my($name,$desc) = @_ ? @_ : GetOSName();
277     $name =~ s/^Win//;
278     if ($desc =~ /^Windows Home Server\b/ || $desc =~ /^Windows XP Professional x64 Edition\b/) {
279         ($name, $desc) = ($desc, "");
280     }
281     elsif ($desc =~ s/\s*(Windows (.*) Server( \d+)?)//) {
282         $name = "$1 $name";
283         $desc =~ s/^\s+//;
284     }
285     else {
286         for ($name) {
287             s/^/Windows / unless /^Win32s$/;
288             s/\/.Net//;
289             s/NT(\d)/NT $1/;
290             if ($desc =~ s/\s*(HPC|Small Business|Web) Server//) {
291                 my $name = $1;
292                 $desc =~ s/^\s*//;
293                 s/(200.)/$name Server $1/;
294             }
295             s/^Windows (20(03|08|12))/Windows Server $1/;
296         }
297     }
298     $name .= " $desc" if length $desc;
299     return $name;
300 }
301
302 sub _GetSystemMetrics {
303     my($index,$metrics) = @_;
304     return Win32::GetSystemMetrics($index) unless ref $metrics;
305     return $metrics->{$index} if ref $metrics eq "HASH" && defined $metrics->{$index};
306     return 1 if ref $metrics eq "ARRAY" && grep $_ == $index, @$metrics;
307     return 0;
308 }
309
310 sub _GetOSName {
311     # The $metrics argument only exists for the benefit of t/GetOSName.t
312     my($csd, $major, $minor, $build, $id, $suitemask, $producttype, $productinfo, $arch, $metrics) = @_;
313
314     my($os,@tags);
315     my $desc = "";
316     if ($id == 0) {
317         $os = "Win32s";
318     }
319     elsif ($id == 1) {
320         if ($minor == 0) {
321             $os = "95";
322         }
323         elsif ($minor == 10) {
324             $os = "98";
325         }
326         elsif ($minor == 90) {
327             $os = "Me";
328         }
329     }
330     elsif ($id == 2) {
331         if ($major == 3) {
332             $os = "NT3.51";
333         }
334         elsif ($major == 4) {
335             $os = "NT4";
336         }
337         elsif ($major == 5) {
338             if ($minor == 0) {
339                 $os = "2000";
340                 if ($producttype == VER_NT_WORKSTATION) {
341                     $desc = "Professional";
342                 }
343                 else {
344                     if ($suitemask & VER_SUITE_DATACENTER) {
345                         $desc = "Datacenter Server";
346                     }
347                     elsif ($suitemask & VER_SUITE_ENTERPRISE) {
348                         $desc = "Advanced Server";
349                     }
350                     elsif ($suitemask & VER_SUITE_SMALLBUSINESS_RESTRICTED) {
351                         $desc = "Small Business Server";
352                     }
353                     else {
354                         $desc = "Server";
355                     }
356                 }
357                 # XXX ignoring "Windows 2000 Advanced Server Limited Edition" for Itanium
358                 # XXX and "Windows 2000 Datacenter Server Limited Edition" for Itanium
359             }
360             elsif ($minor == 1) {
361                 $os = "XP/.Net";
362                 if (_GetSystemMetrics(SM_MEDIACENTER, $metrics)) {
363                     $desc = "Media Center Edition";
364                 }
365                 elsif (_GetSystemMetrics(SM_TABLETPC, $metrics)) {
366                     # Tablet PC Edition is based on XP Pro
367                     $desc = "Tablet PC Edition";
368                 }
369                 elsif (_GetSystemMetrics(SM_STARTER, $metrics)) {
370                     $desc = "Starter Edition";
371                 }
372                 elsif ($suitemask & VER_SUITE_PERSONAL) {
373                     $desc = "Home Edition";
374                 }
375                 else {
376                     $desc = "Professional";
377                 }
378                 # XXX ignoring all Windows XP Embedded and Fundamentals versions
379             }
380             elsif ($minor == 2) {
381                 $os = "2003";
382
383                 if (_GetSystemMetrics(SM_SERVERR2, $metrics)) {
384                     # XXX R2 was released for all x86 and x64 versions,
385                     # XXX but only Enterprise Edition for Itanium.
386                     $desc = "R2";
387                 }
388
389                 if ($suitemask == VER_SUITE_STORAGE_SERVER) {
390                     $desc .= " Windows Storage Server";
391                 }
392                 elsif ($suitemask == VER_SUITE_WH_SERVER) {
393                     $desc .= " Windows Home Server";
394                 }
395                 elsif ($producttype == VER_NT_WORKSTATION && $arch == PROCESSOR_ARCHITECTURE_AMD64) {
396                     $desc .= " Windows XP Professional x64 Edition";
397                 }
398
399                 # Test for the server type.
400                 if ($producttype != VER_NT_WORKSTATION) {
401                     if ($arch == PROCESSOR_ARCHITECTURE_IA64) {
402                         if ($suitemask & VER_SUITE_DATACENTER) {
403                             $desc .= " Datacenter Edition for Itanium-based Systems";
404                         }
405                         elsif ($suitemask & VER_SUITE_ENTERPRISE) {
406                             $desc .= " Enterprise Edition for Itanium-based Systems";
407                         }
408                     }
409                     elsif ($arch == PROCESSOR_ARCHITECTURE_AMD64) {
410                         if ($suitemask & VER_SUITE_DATACENTER) {
411                             $desc .= " Datacenter x64 Edition";
412                         }
413                         elsif ($suitemask & VER_SUITE_ENTERPRISE) {
414                             $desc .= " Enterprise x64 Edition";
415                         }
416                         else {
417                             $desc .= " Standard x64 Edition";
418                         }
419                     }
420                     else {
421                         if ($suitemask & VER_SUITE_COMPUTE_SERVER) {
422                             $desc .= " Windows Compute Cluster Server";
423                         }
424                         elsif ($suitemask & VER_SUITE_DATACENTER) {
425                             $desc .= " Datacenter Edition";
426                         }
427                         elsif ($suitemask & VER_SUITE_ENTERPRISE) {
428                             $desc .= " Enterprise Edition";
429                         }
430                         elsif ($suitemask & VER_SUITE_BLADE) {
431                             $desc .= " Web Edition";
432                         }
433                         elsif ($suitemask & VER_SUITE_SMALLBUSINESS_RESTRICTED) {
434                             $desc .= " Small Business Server";
435                         }
436                         else {
437                             if ($desc !~ /Windows (Home|Storage) Server/) {
438                                 $desc .= " Standard Edition";
439                             }
440                         }
441                     }
442                 }
443             }
444         }
445         elsif ($major == 6) {
446             if ($minor == 0) {
447                 if ($producttype == VER_NT_WORKSTATION) {
448                     $os = "Vista";
449                 }
450                 else {
451                     $os = "2008";
452                 }
453             }
454             elsif ($minor == 1) {
455                 if ($producttype == VER_NT_WORKSTATION) {
456                     $os = "7";
457                 }
458                 else {
459                     $os = "2008";
460                     $desc = "R2";
461                 }
462             }
463             elsif ($minor == 2) {
464             if ($producttype == VER_NT_WORKSTATION) {
465                 $os = "8";
466             }
467             else {
468                 $os = "2012";
469             }
470             }
471
472         if ($productinfo == PRODUCT_ULTIMATE) {
473                 $desc .= " Ultimate";
474             }
475             elsif ($productinfo == PRODUCT_HOME_PREMIUM) {
476                $desc .= " Home Premium";
477             }
478             elsif ($productinfo == PRODUCT_HOME_BASIC) {
479                $desc .= " Home Basic";
480             }
481             elsif ($productinfo == PRODUCT_ENTERPRISE) {
482                $desc .= " Enterprise";
483             }
484             elsif ($productinfo == PRODUCT_BUSINESS) {
485                # "Windows 7 Business" had a name change to "Windows 7 Professional"
486                $desc .= $minor == 0 ? " Business" : " Professional";
487             }
488             elsif ($productinfo == PRODUCT_STARTER) {
489                $desc .= " Starter";
490             }
491             elsif ($productinfo == PRODUCT_CLUSTER_SERVER) {
492                $desc .= " HPC Server";
493             }
494             elsif ($productinfo == PRODUCT_DATACENTER_SERVER) {
495                $desc .= " Datacenter";
496             }
497             elsif ($productinfo == PRODUCT_DATACENTER_SERVER_CORE) {
498                $desc .= " Datacenter Edition (core installation)";
499             }
500             elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER) {
501                $desc .= " Enterprise";
502             }
503             elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_CORE) {
504                $desc .= " Enterprise Edition (core installation)";
505             }
506             elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_IA64) {
507                $desc .= " Enterprise Edition for Itanium-based Systems";
508             }
509             elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER) {
510                $desc .= " Small Business Server";
511             }
512             elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER_PREMIUM) {
513                $desc .= " Small Business Server Premium Edition";
514             }
515             elsif ($productinfo == PRODUCT_STANDARD_SERVER) {
516                $desc .= " Standard";
517             }
518             elsif ($productinfo == PRODUCT_STANDARD_SERVER_CORE) {
519                $desc .= " Standard Edition (core installation)";
520             }
521             elsif ($productinfo == PRODUCT_WEB_SERVER) {
522                $desc .= " Web Server";
523             }
524             elsif ($productinfo == PRODUCT_PROFESSIONAL) {
525                $desc .= " Professional";
526             }
527
528             if ($arch == PROCESSOR_ARCHITECTURE_INTEL) {
529                 $desc .= " (32-bit)";
530             }
531             elsif ($arch == PROCESSOR_ARCHITECTURE_AMD64) {
532                 $desc .= " (64-bit)";
533             }
534         }
535     }
536
537     unless (defined $os) {
538         warn "Unknown Windows version [$id:$major:$minor]";
539         return;
540     }
541
542     for ($desc) {
543         s/\s\s+/ /g;
544         s/^\s//;
545         s/\s$//;
546     }
547
548     # XXX What about "Small Business Server"? NT, 200, 2003, 2008 editions...
549
550     if ($major >= 5) {
551         # XXX XP, Vista, 7 all have starter editions
552         #push(@tags, "Starter Edition") if _GetSystemMetrics(SM_STARTER, $metrics);
553     }
554
555     if (@tags) {
556         unshift(@tags, $desc) if length $desc;
557         $desc = join(" ", @tags);
558     }
559
560     if (length $csd) {
561         $desc .= " " if length $desc;
562         $desc .= $csd;
563     }
564     return ("Win$os", $desc);
565 }
566
567 # "no warnings 'redefine';" doesn't work for 5.8.7 and earlier
568 local $^W = 0;
569 bootstrap Win32;
570
571 1;
572
573 __END__
574
575 =head1 NAME
576
577 Win32 - Interfaces to some Win32 API Functions
578
579 =head1 DESCRIPTION
580
581 The Win32 module contains functions to access Win32 APIs.
582
583 =head2 Alphabetical Listing of Win32 Functions
584
585 It is recommended to C<use Win32;> before any of these functions;
586 however, for backwards compatibility, those marked as [CORE] will
587 automatically do this for you.
588
589 In the function descriptions below the term I<Unicode string> is used
590 to indicate that the string may contain characters outside the system
591 codepage.  The caveat I<If supported by the core Perl version>
592 generally means Perl 5.8.9 and later, though some Unicode pathname
593 functionality may work on earlier versions.
594
595 =over
596
597 =item Win32::AbortSystemShutdown(MACHINE)
598
599 Aborts a system shutdown (started by the
600 InitiateSystemShutdown function) on the specified MACHINE.
601
602 =item Win32::BuildNumber()
603
604 [CORE] Returns the ActivePerl build number.  This function is
605 only available in the ActivePerl binary distribution.
606
607 =item Win32::CopyFile(FROM, TO, OVERWRITE)
608
609 [CORE] The Win32::CopyFile() function copies an existing file to a new
610 file.  All file information like creation time and file attributes will
611 be copied to the new file.  However it will B<not> copy the security
612 information.  If the destination file already exists it will only be
613 overwritten when the OVERWRITE parameter is true.  But even this will
614 not overwrite a read-only file; you have to unlink() it first
615 yourself.
616
617 =item Win32::CreateDirectory(DIRECTORY)
618
619 Creates the DIRECTORY and returns a true value on success.  Check $^E
620 on failure for extended error information.
621
622 DIRECTORY may contain Unicode characters outside the system codepage.
623 Once the directory has been created you can use
624 Win32::GetANSIPathName() to get a name that can be passed to system
625 calls and external programs.
626
627 =item Win32::CreateFile(FILE)
628
629 Creates the FILE and returns a true value on success.  Check $^E on
630 failure for extended error information.
631
632 FILE may contain Unicode characters outside the system codepage.  Once
633 the file has been created you can use Win32::GetANSIPathName() to get
634 a name that can be passed to system calls and external programs.
635
636 =item Win32::DomainName()
637
638 [CORE] Returns the name of the Microsoft Network domain or workgroup
639 that the owner of the current perl process is logged into.  The
640 "Workstation" service must be running to determine this
641 information.  This function does B<not> work on Windows 9x.
642
643 =item Win32::ExpandEnvironmentStrings(STRING)
644
645 Takes STRING and replaces all referenced environment variable
646 names with their defined values.  References to environment variables
647 take the form C<%VariableName%>.  Case is ignored when looking up the
648 VariableName in the environment.  If the variable is not found then the
649 original C<%VariableName%> text is retained.  Has the same effect
650 as the following:
651
652         $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg
653
654 However, this function may return a Unicode string if the environment
655 variable being expanded hasn't been assigned to via %ENV.  Access
656 to %ENV is currently always using byte semantics.
657
658 =item Win32::FormatMessage(ERRORCODE)
659
660 [CORE] Converts the supplied Win32 error number (e.g. returned by
661 Win32::GetLastError()) to a descriptive string.  Analogous to the
662 perror() standard-C library function.  Note that C<$^E> used
663 in a string context has much the same effect.
664
665         C:\> perl -e "$^E = 26; print $^E;"
666         The specified disk or diskette cannot be accessed
667
668 =item Win32::FsType()
669
670 [CORE] Returns the name of the filesystem of the currently active
671 drive (like 'FAT' or 'NTFS').  In list context it returns three values:
672 (FSTYPE, FLAGS, MAXCOMPLEN).  FSTYPE is the filesystem type as
673 before.  FLAGS is a combination of values of the following table:
674
675         0x00000001  supports case-sensitive filenames
676         0x00000002  preserves the case of filenames
677         0x00000004  supports Unicode in filenames
678         0x00000008  preserves and enforces ACLs
679         0x00000010  supports file-based compression
680         0x00000020  supports disk quotas
681         0x00000040  supports sparse files
682         0x00000080  supports reparse points
683         0x00000100  supports remote storage
684         0x00008000  is a compressed volume (e.g. DoubleSpace)
685         0x00010000  supports object identifiers
686         0x00020000  supports the Encrypted File System (EFS)
687
688 MAXCOMPLEN is the maximum length of a filename component (the part
689 between two backslashes) on this file system.
690
691 =item Win32::FreeLibrary(HANDLE)
692
693 Unloads a previously loaded dynamic-link library.  The HANDLE is
694 no longer valid after this call.  See L<LoadLibrary|Win32::LoadLibrary(LIBNAME)>
695 for information on dynamically loading a library.
696
697 =item Win32::GetACP()
698
699 Returns the current Windows ANSI code page identifier for the operating
700 system.  See also GetOEMCP(), GetConsoleCP() and GetConsoleOutputCP().
701
702 =item Win32::GetANSIPathName(FILENAME)
703
704 Returns an ANSI version of FILENAME.  This may be the short name
705 if the long name cannot be represented in the system codepage.
706
707 While not currently implemented, it is possible that in the future
708 this function will convert only parts of the path to FILENAME to a
709 short form.
710
711 If FILENAME doesn't exist on the filesystem, or if the filesystem
712 doesn't support short ANSI filenames, then this function will
713 translate the Unicode name into the system codepage using replacement
714 characters.
715
716 =item Win32::GetArchName()
717
718 Use of this function is deprecated.  It is equivalent with
719 $ENV{PROCESSOR_ARCHITECTURE}.  This might not work on Win9X.
720
721 =item Win32::GetChipName()
722
723 Returns the processor type: 386, 486 or 586 for x86 processors, 8664
724 for the x64 processor and 2200 for the Itanium.  Since it returns the
725 native processor type it will return a 64-bit processor type even when
726 called from a 32-bit Perl running on 64-bit Windows.
727
728 =item Win32::GetConsoleCP()
729
730 Returns the input code page used by the console associated with the
731 calling process.  To set the console's input code page, see
732 SetConsoleCP().  See also GetConsoleOutputCP(), GetACP() and
733 GetOEMCP().
734
735 =item Win32::GetConsoleOutputCP()
736
737 Returns the output code page used by the console associated with the
738 calling process.  To set the console's output code page, see
739 SetConsoleOutputCP().  See also GetConsoleCP(), GetACP(), and
740 GetOEMCP().
741
742 =item Win32::GetCwd()
743
744 [CORE] Returns the current active drive and directory.  This function
745 does not return a UNC path, since the functionality required for such
746 a feature is not available under Windows 95.
747
748 If supported by the core Perl version, this function will return an
749 ANSI path name for the current directory if the long pathname cannot
750 be represented in the system codepage.
751
752 =item Win32::GetCurrentProcessId()
753
754 Returns the process identifier of the current process.  Until the
755 process terminates, the process identifier uniquely identifies the
756 process throughout the system.
757
758 The current process identifier is normally also available via the
759 predefined $$ variable.  Under fork() emulation however $$ may contain
760 a pseudo-process identifier that is only meaningful to the Perl
761 kill(), wait() and waitpid() functions.  The
762 Win32::GetCurrentProcessId() function will always return the regular
763 Windows process id, even when called from inside a pseudo-process.
764
765 =item Win32::GetCurrentThreadId()
766
767 Returns the thread identifier of the calling thread.  Until the thread
768 terminates, the thread identifier uniquely identifies the thread
769 throughout the system.
770
771 =item Win32::GetFileVersion(FILENAME)
772
773 Returns the file version number from the VERSIONINFO resource of
774 the executable file or DLL.  This is a tuple of four 16 bit numbers.
775 In list context these four numbers will be returned.  In scalar context
776 they are concatenated into a string, separated by dots.
777
778 =item Win32::GetFolderPath(FOLDER [, CREATE])
779
780 Returns the full pathname of one of the Windows special folders.
781 The folder will be created if it doesn't exist and the optional CREATE
782 argument is true.  The following FOLDER constants are defined by the
783 Win32 module, but only exported on demand:
784
785         CSIDL_ADMINTOOLS
786         CSIDL_APPDATA
787         CSIDL_CDBURN_AREA
788         CSIDL_COMMON_ADMINTOOLS
789         CSIDL_COMMON_APPDATA
790         CSIDL_COMMON_DESKTOPDIRECTORY
791         CSIDL_COMMON_DOCUMENTS
792         CSIDL_COMMON_FAVORITES
793         CSIDL_COMMON_MUSIC
794         CSIDL_COMMON_PICTURES
795         CSIDL_COMMON_PROGRAMS
796         CSIDL_COMMON_STARTMENU
797         CSIDL_COMMON_STARTUP
798         CSIDL_COMMON_TEMPLATES
799         CSIDL_COMMON_VIDEO
800         CSIDL_COOKIES
801         CSIDL_DESKTOP
802         CSIDL_DESKTOPDIRECTORY
803         CSIDL_FAVORITES
804         CSIDL_FONTS
805         CSIDL_HISTORY
806         CSIDL_INTERNET_CACHE
807         CSIDL_LOCAL_APPDATA
808         CSIDL_MYMUSIC
809         CSIDL_MYPICTURES
810         CSIDL_MYVIDEO
811         CSIDL_NETHOOD
812         CSIDL_PERSONAL
813         CSIDL_PRINTHOOD
814         CSIDL_PROFILE
815         CSIDL_PROGRAMS
816         CSIDL_PROGRAM_FILES
817         CSIDL_PROGRAM_FILES_COMMON
818         CSIDL_RECENT
819         CSIDL_RESOURCES
820         CSIDL_RESOURCES_LOCALIZED
821         CSIDL_SENDTO
822         CSIDL_STARTMENU
823         CSIDL_STARTUP
824         CSIDL_SYSTEM
825         CSIDL_TEMPLATES
826         CSIDL_WINDOWS
827
828 Note that not all folders are defined on all versions of Windows.
829
830 Please refer to the MSDN documentation of the CSIDL constants,
831 currently available at:
832
833 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
834
835 This function will return an ANSI folder path if the long name cannot
836 be represented in the system codepage.  Use Win32::GetLongPathName()
837 on the result of Win32::GetFolderPath() if you want the Unicode
838 version of the folder name.
839
840 =item Win32::GetFullPathName(FILENAME)
841
842 [CORE] GetFullPathName combines the FILENAME with the current drive
843 and directory name and returns a fully qualified (aka, absolute)
844 path name.  In list context it returns two elements: (PATH, FILE) where
845 PATH is the complete pathname component (including trailing backslash)
846 and FILE is just the filename part.  Note that no attempt is made to
847 convert 8.3 components in the supplied FILENAME to longnames or
848 vice-versa.  Compare with Win32::GetShortPathName() and
849 Win32::GetLongPathName().
850
851 If supported by the core Perl version, this function will return an
852 ANSI path name if the full pathname cannot be represented in the
853 system codepage.
854
855 =item Win32::GetLastError()
856
857 [CORE] Returns the last error value generated by a call to a Win32 API
858 function.  Note that C<$^E> used in a numeric context amounts to the
859 same value.
860
861 =item Win32::GetLongPathName(PATHNAME)
862
863 [CORE] Returns a representation of PATHNAME composed of longname
864 components (if any).  The result may not necessarily be longer
865 than PATHNAME.  No attempt is made to convert PATHNAME to the
866 absolute path.  Compare with Win32::GetShortPathName() and
867 Win32::GetFullPathName().
868
869 This function may return the pathname in Unicode if it cannot be
870 represented in the system codepage.  Use Win32::GetANSIPathName()
871 before passing the path to a system call or another program.
872
873 =item Win32::GetNextAvailDrive()
874
875 [CORE] Returns a string in the form of "<d>:" where <d> is the first
876 available drive letter.
877
878 =item Win32::GetOEMCP()
879
880 Returns the current original equipment manufacturer (OEM) code page
881 identifier for the operating system.  See also GetACP(), GetConsoleCP()
882 and GetConsoleOutputCP().
883
884 =item Win32::GetOSDisplayName()
885
886 Returns the "marketing" name of the Windows operating system version
887 being used.  It returns names like these (random samples):
888
889    Windows 2000 Datacenter Server
890    Windows XP Professional
891    Windows XP Tablet PC Edition
892    Windows Home Server
893    Windows Server 2003 Enterprise Edition for Itanium-based Systems
894    Windows Vista Ultimate (32-bit)
895    Windows Small Business Server 2008 R2 (64-bit)
896
897 The display name describes the native Windows version, so even on a
898 32-bit Perl this function may return a "Windows ... (64-bit)" name
899 when running on a 64-bit Windows.
900
901 This function should only be used to display the actual OS name to the
902 user; it should not be used to determine the class of operating systems
903 this system belongs to.  The Win32::GetOSName(), Win32::GetOSVersion,
904 Win32::GetProductInfo() and Win32::GetSystemMetrics() functions provide
905 the base information to check for certain capabilities, or for families
906 of OS releases.
907
908 =item Win32::GetOSName()
909
910 In scalar context returns the name of the Win32 operating system
911 being used.  In list context returns a two element list of the OS name
912 and whatever edition information is known about the particular build
913 (for Win9X boxes) and whatever service packs have been installed.
914 The latter is roughly equivalent to the first item returned by
915 GetOSVersion() in list context.
916
917 The description will also include tags for other special editions,
918 like "R2", "Media Center", "Tablet PC", or "Starter Edition".
919
920 Currently the possible values for the OS name are
921
922     WinWin32s
923     Win95
924     Win98
925     WinMe
926     WinNT3.51
927     WinNT4
928     Win2000
929     WinXP/.Net
930     Win2003
931     WinHomeSvr
932     WinVista
933     Win2008
934     Win7
935
936 This routine is just a simple interface into GetOSVersion().  More
937 specific or demanding situations should use that instead.  Another
938 option would be to use POSIX::uname(), however the latter appears to
939 report only the OS family name and not the specific OS.  In scalar
940 context it returns just the ID.
941
942 The name "WinXP/.Net" is used for historical reasons only, to maintain
943 backwards compatibility of the Win32 module.  Windows .NET Server has
944 been renamed as Windows 2003 Server before final release and uses a
945 different major/minor version number than Windows XP.
946
947 Similarly the name "WinWin32s" should have been "Win32s" but has been
948 kept as-is for backwards compatibility reasons too.
949
950 =item Win32::GetOSVersion()
951
952 [CORE] Returns the list (STRING, MAJOR, MINOR, BUILD, ID), where the
953 elements are, respectively: An arbitrary descriptive string, the major
954 version number of the operating system, the minor version number, the
955 build number, and a digit indicating the actual operating system.
956 For the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for
957 Windows NT/2000/XP/2003/Vista/2008/7.  In scalar context it returns just
958 the ID.
959
960 Currently known values for ID MAJOR and MINOR are as follows:
961
962     OS                      ID    MAJOR   MINOR
963     Win32s                   0      -       -
964     Windows 95               1      4       0
965     Windows 98               1      4      10
966     Windows Me               1      4      90
967
968     Windows NT 3.51          2      3      51
969     Windows NT 4             2      4       0
970
971     Windows 2000             2      5       0
972     Windows XP               2      5       1
973     Windows Server 2003      2      5       2
974     Windows Server 2003 R2   2      5       2
975     Windows Home Server      2      5       2
976
977     Windows Vista            2      6       0
978     Windows Server 2008      2      6       0
979     Windows 7                2      6       1
980     Windows Server 2008 R2   2      6       1
981     Windows 8                2      6       2
982     Windows Server 2012      2      6       2
983
984 On Windows NT 4 SP6 and later this function returns the following
985 additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.
986
987 The version numbers for Windows 2003 and Windows Home Server are
988 identical; the SUITEMASK field must be used to differentiate between\
989 them.
990
991 The version numbers for Windows Vista and Windows Server 2008 are
992 identical; the PRODUCTTYPE field must be used to differentiate between
993 them.
994
995 The version numbers for Windows 7 and Windows Server 2008 R2 are
996 identical; the PRODUCTTYPE field must be used to differentiate between
997 them.
998
999 The version numbers for Windows 8 and Windows Server 2012 are
1000 identical; the PRODUCTTYPE field must be used to differentiate between
1001 them.
1002
1003 SPMAJOR and SPMINOR are are the version numbers of the latest
1004 installed service pack.
1005
1006 SUITEMASK is a bitfield identifying the product suites available on
1007 the system.  Known bits are:
1008
1009     VER_SUITE_SMALLBUSINESS             0x00000001
1010     VER_SUITE_ENTERPRISE                0x00000002
1011     VER_SUITE_BACKOFFICE                0x00000004
1012     VER_SUITE_COMMUNICATIONS            0x00000008
1013     VER_SUITE_TERMINAL                  0x00000010
1014     VER_SUITE_SMALLBUSINESS_RESTRICTED  0x00000020
1015     VER_SUITE_EMBEDDEDNT                0x00000040
1016     VER_SUITE_DATACENTER                0x00000080
1017     VER_SUITE_SINGLEUSERTS              0x00000100
1018     VER_SUITE_PERSONAL                  0x00000200
1019     VER_SUITE_BLADE                     0x00000400
1020     VER_SUITE_EMBEDDED_RESTRICTED       0x00000800
1021     VER_SUITE_SECURITY_APPLIANCE        0x00001000
1022     VER_SUITE_STORAGE_SERVER            0x00002000
1023     VER_SUITE_COMPUTE_SERVER            0x00004000
1024     VER_SUITE_WH_SERVER                 0x00008000
1025
1026 The VER_SUITE_xxx names are listed here to crossreference the Microsoft
1027 documentation.  The Win32 module does not provide symbolic names for these
1028 constants.
1029
1030 PRODUCTTYPE provides additional information about the system.  It should
1031 be one of the following integer values:
1032
1033     1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro, Vista, etc)
1034     2 - Domaincontroller
1035     3 - Server (2000 Server, Server 2003, Server 2008, etc)
1036
1037 Note that a server that is also a domain controller is reported as
1038 PRODUCTTYPE 2 (Domaincontroller) and not PRODUCTTYPE 3 (Server).
1039
1040 =item Win32::GetShortPathName(PATHNAME)
1041
1042 [CORE] Returns a representation of PATHNAME that is composed of short
1043 (8.3) path components where available.  For path components where the
1044 file system has not generated the short form the returned path will
1045 use the long form, so this function might still for instance return a
1046 path containing spaces.  Returns C<undef> when the PATHNAME does not
1047 exist. Compare with Win32::GetFullPathName() and
1048 Win32::GetLongPathName().
1049
1050 =item Win32::GetSystemMetrics(INDEX)
1051
1052 Retrieves the specified system metric or system configuration setting.
1053 Please refer to the Microsoft documentation of the GetSystemMetrics()
1054 function for a reference of available INDEX values.  All system
1055 metrics return integer values.
1056
1057 =item Win32::GetProcAddress(INSTANCE, PROCNAME)
1058
1059 Returns the address of a function inside a loaded library.  The
1060 information about what you can do with this address has been lost in
1061 the mist of time.  Use the Win32::API module instead of this deprecated
1062 function.
1063
1064 =item Win32::GetProductInfo(OSMAJOR, OSMINOR, SPMAJOR, SPMINOR)
1065
1066 Retrieves the product type for the operating system on the local
1067 computer, and maps the type to the product types supported by the
1068 specified operating system.  Please refer to the Microsoft
1069 documentation of the GetProductInfo() function for more information
1070 about the parameters and return value.  This function requires Windows
1071 Vista or later.
1072
1073 See also the Win32::GetOSName() and Win32::GetOSDisplayName()
1074 functions which provide a higher level abstraction of the data
1075 returned by this function.
1076
1077 =item Win32::GetTickCount()
1078
1079 [CORE] Returns the number of milliseconds elapsed since the last
1080 system boot.  Resolution is limited to system timer ticks (about 10ms
1081 on WinNT and 55ms on Win9X).
1082
1083 =item Win32::GuidGen()
1084
1085 Creates a globally unique 128 bit integer that can be used as a
1086 persistent identifier in a distributed setting. To a very high degree
1087 of certainty this function returns a unique value. No other
1088 invocation, on the same or any other system (networked or not), should
1089 return the same value.
1090
1091 The return value is formatted according to OLE conventions, as groups
1092 of hex digits with surrounding braces.  For example:
1093
1094     {09531CF1-D0C7-4860-840C-1C8C8735E2AD}
1095
1096 =item Win32::InitiateSystemShutdown
1097
1098 (MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)
1099
1100 Shutsdown the specified MACHINE, notifying users with the
1101 supplied MESSAGE, within the specified TIMEOUT interval.  Forces
1102 closing of all documents without prompting the user if FORCECLOSE is
1103 true, and reboots the machine if REBOOT is true.  This function works
1104 only on WinNT.
1105
1106 =item Win32::IsAdminUser()
1107
1108 Returns non zero if the account in whose security context the
1109 current process/thread is running belongs to the local group of
1110 Administrators in the built-in system domain; returns 0 if not.
1111 On Windows Vista it will only return non-zero if the process is
1112 actually running with elevated privileges.  Returns C<undef>
1113 and prints a warning if an error occurred.  This function always
1114 returns 1 on Win9X.
1115
1116 =item Win32::IsWinNT()
1117
1118 [CORE] Returns non zero if the Win32 subsystem is Windows NT.
1119
1120 =item Win32::IsWin95()
1121
1122 [CORE] Returns non zero if the Win32 subsystem is Windows 95.
1123
1124 =item Win32::LoadLibrary(LIBNAME)
1125
1126 Loads a dynamic link library into memory and returns its module
1127 handle.  This handle can be used with Win32::GetProcAddress() and
1128 Win32::FreeLibrary().  This function is deprecated.  Use the Win32::API
1129 module instead.
1130
1131 =item Win32::LoginName()
1132
1133 [CORE] Returns the username of the owner of the current perl process.
1134 The return value may be a Unicode string.
1135
1136 =item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE)
1137
1138 Looks up ACCOUNT on SYSTEM and returns the domain name the SID and
1139 the SID type.
1140
1141 =item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE)
1142
1143 Looks up SID on SYSTEM and returns the account name, domain name,
1144 and the SID type.
1145
1146 =item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])
1147
1148 Create a dialogbox containing MESSAGE.  FLAGS specifies the
1149 required icon and buttons according to the following table:
1150
1151         0 = OK
1152         1 = OK and Cancel
1153         2 = Abort, Retry, and Ignore
1154         3 = Yes, No and Cancel
1155         4 = Yes and No
1156         5 = Retry and Cancel
1157
1158         MB_ICONSTOP          "X" in a red circle
1159         MB_ICONQUESTION      question mark in a bubble
1160         MB_ICONEXCLAMATION   exclamation mark in a yellow triangle
1161         MB_ICONINFORMATION   "i" in a bubble
1162
1163 TITLE specifies an optional window title.  The default is "Perl".
1164
1165 The function returns the menu id of the selected push button:
1166
1167         0  Error
1168
1169         1  OK
1170         2  Cancel
1171         3  Abort
1172         4  Retry
1173         5  Ignore
1174         6  Yes
1175         7  No
1176
1177 =item Win32::NodeName()
1178
1179 [CORE] Returns the Microsoft Network node-name of the current machine.
1180
1181 =item Win32::OutputDebugString(STRING)
1182
1183 Sends a string to the application or system debugger for display.
1184 The function does nothing if there is no active debugger.
1185
1186 Alternatively one can use the I<Debug Viewer> application to
1187 watch the OutputDebugString() output:
1188
1189 http://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx
1190
1191 =item Win32::RegisterServer(LIBRARYNAME)
1192
1193 Loads the DLL LIBRARYNAME and calls the function DllRegisterServer.
1194
1195 =item Win32::SetChildShowWindow(SHOWWINDOW)
1196
1197 [CORE] Sets the I<ShowMode> of child processes started by system().
1198 By default system() will create a new console window for child
1199 processes if Perl itself is not running from a console.  Calling
1200 SetChildShowWindow(0) will make these new console windows invisible.
1201 Calling SetChildShowWindow() without arguments reverts system() to the
1202 default behavior.  The return value of SetChildShowWindow() is the
1203 previous setting or C<undef>.
1204
1205 The following symbolic constants for SHOWWINDOW are available
1206 (but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL,
1207 SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE.
1208
1209 =item Win32::SetConsoleCP(ID)
1210
1211 Sets the input code page used by the console associated with the
1212 calling process.  The return value of SetConsoleCP() is nonzero on
1213 success or zero on failure.  To get the console's input code page, see
1214 GetConsoleCP().
1215
1216 =item Win32::SetConsoleOutputCP(ID)
1217
1218 Sets the output code page used by the console associated with the
1219 calling process.  The return value of SetConsoleOutputCP() is nonzero on
1220 success or zero on failure.  To get the console's output code page, see
1221 GetConsoleOutputCP().
1222
1223 =item Win32::SetCwd(NEWDIRECTORY)
1224
1225 [CORE] Sets the current active drive and directory.  This function does not
1226 work with UNC paths, since the functionality required to required for
1227 such a feature is not available under Windows 95.
1228
1229 =item Win32::SetLastError(ERROR)
1230
1231 [CORE] Sets the value of the last error encountered to ERROR.  This is
1232 that value that will be returned by the Win32::GetLastError()
1233 function.
1234
1235 =item Win32::Sleep(TIME)
1236
1237 [CORE] Pauses for TIME milliseconds.  The timeslices are made available
1238 to other processes and threads.
1239
1240 =item Win32::Spawn(COMMAND, ARGS, PID)
1241
1242 [CORE] Spawns a new process using the supplied COMMAND, passing in
1243 arguments in the string ARGS.  The pid of the new process is stored in
1244 PID.  This function is deprecated.  Please use the Win32::Process module
1245 instead.
1246
1247 =item Win32::UnregisterServer(LIBRARYNAME)
1248
1249 Loads the DLL LIBRARYNAME and calls the function
1250 DllUnregisterServer.
1251
1252 =back
1253
1254 =cut