Filename | C:/tmp64ng/perl/lib/Win32.pm |
Statements | Executed 16 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 0s | 0s | BEGIN@4 | Win32::
1 | 1 | 1 | 0s | 0s | BEGIN@5 | Win32::
0 | 0 | 0 | 0s | 0s | DACL_SECURITY_INFORMATION | Win32::
0 | 0 | 0 | 0s | 0s | GROUP_SECURITY_INFORMATION | Win32::
15 | 1 | 1 | 0s | 0s | GetCwd (xsub) | Win32::
0 | 0 | 0 | 0s | 0s | GetOSDisplayName | Win32::
0 | 0 | 0 | 0s | 0s | GetOSName | Win32::
6 | 1 | 1 | 0s | 0s | GetShortPathName (xsub) | Win32::
1 | 1 | 1 | 0s | 0s | IsWin95 (xsub) | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONASTERISK | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONERROR | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONEXCLAMATION | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONHAND | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONINFORMATION | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONQUESTION | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONSTOP | Win32::
0 | 0 | 0 | 0s | 0s | MB_ICONWARNING | Win32::
0 | 0 | 0 | 0s | 0s | NULL | Win32::
0 | 0 | 0 | 0s | 0s | OWNER_SECURITY_INFORMATION | Win32::
0 | 0 | 0 | 0s | 0s | SACL_SECURITY_INFORMATION | Win32::
0 | 0 | 0 | 0s | 0s | WIN31_CLASS | Win32::
0 | 0 | 0 | 0s | 0s | _GetOSName | Win32::
0 | 0 | 0 | 0s | 0s | _GetProcessorArchitecture | Win32::
0 | 0 | 0 | 0s | 0s | _GetSystemMetrics | Win32::
1 | 1 | 1 | 0s | 0s | bootstrap (xsub) | Win32::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Win32; | ||||
2 | |||||
3 | # BEGIN { | ||||
4 | 2 | 0s | 2 | 0s | # spent 0s within Win32::BEGIN@4 which was called:
# once (0s+0s) by ExtUtils::MM::_is_win95 at line 4 # spent 0s making 1 call to Win32::BEGIN@4
# spent 0s making 1 call to strict::import |
5 | 2 | 0s | 2 | 0s | # spent 0s within Win32::BEGIN@5 which was called:
# once (0s+0s) by ExtUtils::MM::_is_win95 at line 5 # spent 0s making 1 call to Win32::BEGIN@5
# spent 0s making 1 call to vars::import |
6 | |||||
7 | 1 | 0s | require Exporter; | ||
8 | 1 | 0s | require DynaLoader; | ||
9 | |||||
10 | 1 | 0s | @ISA = qw|Exporter DynaLoader|; | ||
11 | 1 | 0s | $VERSION = '0.51'; | ||
12 | 1 | 0s | $XS_VERSION = $VERSION; | ||
13 | 1 | 0s | $VERSION = eval $VERSION; # spent 0s executing statements in string eval | ||
14 | |||||
15 | 1 | 0s | @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 | 1 | 0s | @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 | 1 | 0s | 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 | elsif ($minor == 3) { | ||||
472 | if ($producttype == VER_NT_WORKSTATION) { | ||||
473 | $os = "8.1"; | ||||
474 | } | ||||
475 | else { | ||||
476 | $os = "2012"; | ||||
477 | $desc = "R2"; | ||||
478 | } | ||||
479 | } | ||||
480 | |||||
481 | if ($productinfo == PRODUCT_ULTIMATE) { | ||||
482 | $desc .= " Ultimate"; | ||||
483 | } | ||||
484 | elsif ($productinfo == PRODUCT_HOME_PREMIUM) { | ||||
485 | $desc .= " Home Premium"; | ||||
486 | } | ||||
487 | elsif ($productinfo == PRODUCT_HOME_BASIC) { | ||||
488 | $desc .= " Home Basic"; | ||||
489 | } | ||||
490 | elsif ($productinfo == PRODUCT_ENTERPRISE) { | ||||
491 | $desc .= " Enterprise"; | ||||
492 | } | ||||
493 | elsif ($productinfo == PRODUCT_BUSINESS) { | ||||
494 | # "Windows 7 Business" had a name change to "Windows 7 Professional" | ||||
495 | $desc .= $minor == 0 ? " Business" : " Professional"; | ||||
496 | } | ||||
497 | elsif ($productinfo == PRODUCT_STARTER) { | ||||
498 | $desc .= " Starter"; | ||||
499 | } | ||||
500 | elsif ($productinfo == PRODUCT_CLUSTER_SERVER) { | ||||
501 | $desc .= " HPC Server"; | ||||
502 | } | ||||
503 | elsif ($productinfo == PRODUCT_DATACENTER_SERVER) { | ||||
504 | $desc .= " Datacenter"; | ||||
505 | } | ||||
506 | elsif ($productinfo == PRODUCT_DATACENTER_SERVER_CORE) { | ||||
507 | $desc .= " Datacenter Edition (core installation)"; | ||||
508 | } | ||||
509 | elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER) { | ||||
510 | $desc .= " Enterprise"; | ||||
511 | } | ||||
512 | elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_CORE) { | ||||
513 | $desc .= " Enterprise Edition (core installation)"; | ||||
514 | } | ||||
515 | elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_IA64) { | ||||
516 | $desc .= " Enterprise Edition for Itanium-based Systems"; | ||||
517 | } | ||||
518 | elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER) { | ||||
519 | $desc .= " Small Business Server"; | ||||
520 | } | ||||
521 | elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER_PREMIUM) { | ||||
522 | $desc .= " Small Business Server Premium Edition"; | ||||
523 | } | ||||
524 | elsif ($productinfo == PRODUCT_STANDARD_SERVER) { | ||||
525 | $desc .= " Standard"; | ||||
526 | } | ||||
527 | elsif ($productinfo == PRODUCT_STANDARD_SERVER_CORE) { | ||||
528 | $desc .= " Standard Edition (core installation)"; | ||||
529 | } | ||||
530 | elsif ($productinfo == PRODUCT_WEB_SERVER) { | ||||
531 | $desc .= " Web Server"; | ||||
532 | } | ||||
533 | elsif ($productinfo == PRODUCT_PROFESSIONAL) { | ||||
534 | $desc .= " Professional"; | ||||
535 | } | ||||
536 | |||||
537 | if ($arch == PROCESSOR_ARCHITECTURE_INTEL) { | ||||
538 | $desc .= " (32-bit)"; | ||||
539 | } | ||||
540 | elsif ($arch == PROCESSOR_ARCHITECTURE_AMD64) { | ||||
541 | $desc .= " (64-bit)"; | ||||
542 | } | ||||
543 | } | ||||
544 | } | ||||
545 | |||||
546 | unless (defined $os) { | ||||
547 | warn "Unknown Windows version [$id:$major:$minor]"; | ||||
548 | return; | ||||
549 | } | ||||
550 | |||||
551 | for ($desc) { | ||||
552 | s/\s\s+/ /g; | ||||
553 | s/^\s//; | ||||
554 | s/\s$//; | ||||
555 | } | ||||
556 | |||||
557 | # XXX What about "Small Business Server"? NT, 200, 2003, 2008 editions... | ||||
558 | |||||
559 | if ($major >= 5) { | ||||
560 | # XXX XP, Vista, 7 all have starter editions | ||||
561 | #push(@tags, "Starter Edition") if _GetSystemMetrics(SM_STARTER, $metrics); | ||||
562 | } | ||||
563 | |||||
564 | if (@tags) { | ||||
565 | unshift(@tags, $desc) if length $desc; | ||||
566 | $desc = join(" ", @tags); | ||||
567 | } | ||||
568 | |||||
569 | if (length $csd) { | ||||
570 | $desc .= " " if length $desc; | ||||
571 | $desc .= $csd; | ||||
572 | } | ||||
573 | return ("Win$os", $desc); | ||||
574 | } | ||||
575 | |||||
576 | # "no warnings 'redefine';" doesn't work for 5.8.7 and earlier | ||||
577 | 1 | 0s | local $^W = 0; | ||
578 | 1 | 0s | 1 | 0s | bootstrap Win32; # spent 0s making 1 call to DynaLoader::bootstrap |
579 | |||||
580 | 1 | 0s | 1; | ||
581 | |||||
582 | __END__ | ||||
# spent 0s within Win32::GetCwd which was called 15 times, avg 0s/call:
# 15 times (0s+0s) by Cwd::_win32_cwd at line 783 of Cwd.pm, avg 0s/call | |||||
# spent 0s within Win32::GetShortPathName which was called 6 times, avg 0s/call:
# 6 times (0s+0s) by ExtUtils::MM_Win32::_normalize_path_name at line 494 of ExtUtils/MM_Win32.pm, avg 0s/call | |||||
# spent 0s within Win32::IsWin95 which was called:
# once (0s+0s) by ExtUtils::MM::_is_win95 at line 48 of ExtUtils/MM.pm | |||||
# spent 0s within Win32::bootstrap which was called:
# once (0s+0s) by DynaLoader::bootstrap at line 216 of DynaLoader.pm |