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