1package 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.49'; 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 87sub NULL { 0 } 88sub WIN31_CLASS { &NULL } 89 90sub OWNER_SECURITY_INFORMATION { 0x00000001 } 91sub GROUP_SECURITY_INFORMATION { 0x00000002 } 92sub DACL_SECURITY_INFORMATION { 0x00000004 } 93sub SACL_SECURITY_INFORMATION { 0x00000008 } 94 95sub MB_ICONHAND { 0x00000010 } 96sub MB_ICONQUESTION { 0x00000020 } 97sub MB_ICONEXCLAMATION { 0x00000030 } 98sub MB_ICONASTERISK { 0x00000040 } 99sub MB_ICONWARNING { 0x00000030 } 100sub MB_ICONERROR { 0x00000010 } 101sub MB_ICONINFORMATION { 0x00000040 } 102sub 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# 108sub SW_HIDE () { 0 } 109sub SW_SHOWNORMAL () { 1 } 110sub SW_SHOWMINIMIZED () { 2 } 111sub SW_SHOWMAXIMIZED () { 3 } 112sub SW_SHOWNOACTIVATE () { 4 } 113 114sub CSIDL_DESKTOP () { 0x0000 } # <desktop> 115sub CSIDL_PROGRAMS () { 0x0002 } # Start Menu\Programs 116sub CSIDL_PERSONAL () { 0x0005 } # "My Documents" folder 117sub CSIDL_FAVORITES () { 0x0006 } # <user name>\Favorites 118sub CSIDL_STARTUP () { 0x0007 } # Start Menu\Programs\Startup 119sub CSIDL_RECENT () { 0x0008 } # <user name>\Recent 120sub CSIDL_SENDTO () { 0x0009 } # <user name>\SendTo 121sub CSIDL_STARTMENU () { 0x000B } # <user name>\Start Menu 122sub CSIDL_MYMUSIC () { 0x000D } # "My Music" folder 123sub CSIDL_MYVIDEO () { 0x000E } # "My Videos" folder 124sub CSIDL_DESKTOPDIRECTORY () { 0x0010 } # <user name>\Desktop 125sub CSIDL_NETHOOD () { 0x0013 } # <user name>\nethood 126sub CSIDL_FONTS () { 0x0014 } # windows\fonts 127sub CSIDL_TEMPLATES () { 0x0015 } 128sub CSIDL_COMMON_STARTMENU () { 0x0016 } # All Users\Start Menu 129sub CSIDL_COMMON_PROGRAMS () { 0x0017 } # All Users\Start Menu\Programs 130sub CSIDL_COMMON_STARTUP () { 0x0018 } # All Users\Startup 131sub CSIDL_COMMON_DESKTOPDIRECTORY () { 0x0019 } # All Users\Desktop 132sub CSIDL_APPDATA () { 0x001A } # Application Data, new for NT4 133sub CSIDL_PRINTHOOD () { 0x001B } # <user name>\PrintHood 134sub CSIDL_LOCAL_APPDATA () { 0x001C } # non roaming, user\Local Settings\Application Data 135sub CSIDL_COMMON_FAVORITES () { 0x001F } 136sub CSIDL_INTERNET_CACHE () { 0x0020 } 137sub CSIDL_COOKIES () { 0x0021 } 138sub CSIDL_HISTORY () { 0x0022 } 139sub CSIDL_COMMON_APPDATA () { 0x0023 } # All Users\Application Data 140sub CSIDL_WINDOWS () { 0x0024 } # GetWindowsDirectory() 141sub CSIDL_SYSTEM () { 0x0025 } # GetSystemDirectory() 142sub CSIDL_PROGRAM_FILES () { 0x0026 } # C:\Program Files 143sub CSIDL_MYPICTURES () { 0x0027 } # "My Pictures", new for Win2K 144sub CSIDL_PROFILE () { 0x0028 } # USERPROFILE 145sub CSIDL_PROGRAM_FILES_COMMON () { 0x002B } # C:\Program Files\Common 146sub CSIDL_COMMON_TEMPLATES () { 0x002D } # All Users\Templates 147sub CSIDL_COMMON_DOCUMENTS () { 0x002E } # All Users\Documents 148sub CSIDL_COMMON_ADMINTOOLS () { 0x002F } # All Users\Start Menu\Programs\Administrative Tools 149sub CSIDL_ADMINTOOLS () { 0x0030 } # <user name>\Start Menu\Programs\Administrative Tools 150sub CSIDL_COMMON_MUSIC () { 0x0035 } # All Users\My Music 151sub CSIDL_COMMON_PICTURES () { 0x0036 } # All Users\My Pictures 152sub CSIDL_COMMON_VIDEO () { 0x0037 } # All Users\My Video 153sub CSIDL_RESOURCES () { 0x0038 } # %windir%\Resources\, For theme and other windows resources. 154sub CSIDL_RESOURCES_LOCALIZED () { 0x0039 } # %windir%\Resources\<LangID>, for theme and other windows specific resources. 155sub CSIDL_CDBURN_AREA () { 0x003B } # <user name>\Local Settings\Application Data\Microsoft\CD Burning 156 157sub 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. 158sub 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. 160sub VER_NT_WORKSTATION () { 0x0000001 } # The operating system is Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional. 161 162 163sub VER_SUITE_BACKOFFICE () { 0x00000004 } # Microsoft BackOffice components are installed. 164sub VER_SUITE_BLADE () { 0x00000400 } # Windows Server 2003, Web Edition is installed. 165sub VER_SUITE_COMPUTE_SERVER () { 0x00004000 } # Windows Server 2003, Compute Cluster Edition is installed. 166sub VER_SUITE_DATACENTER () { 0x00000080 } # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed. 167sub 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. 168sub VER_SUITE_EMBEDDEDNT () { 0x00000040 } # Windows XP Embedded is installed. 169sub VER_SUITE_PERSONAL () { 0x00000200 } # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed. 170sub 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. 171sub 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. 172sub 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. 173sub VER_SUITE_STORAGE_SERVER () { 0x00002000 } # Windows Storage Server 2003 R2 or Windows Storage Server 2003 is installed. 174sub 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. 176sub VER_SUITE_WH_SERVER () { 0x00008000 } # Windows Home Server is installed. 177 178 179sub SM_TABLETPC () { 86 } 180sub SM_MEDIACENTER () { 87 } 181sub SM_STARTER () { 88 } 182sub SM_SERVERR2 () { 89 } 183 184sub PRODUCT_UNDEFINED () { 0x000 } # An unknown product 185sub PRODUCT_ULTIMATE () { 0x001 } # Ultimate 186sub PRODUCT_HOME_BASIC () { 0x002 } # Home Basic 187sub PRODUCT_HOME_PREMIUM () { 0x003 } # Home Premium 188sub PRODUCT_ENTERPRISE () { 0x004 } # Enterprise 189sub PRODUCT_HOME_BASIC_N () { 0x005 } # Home Basic N 190sub PRODUCT_BUSINESS () { 0x006 } # Business 191sub PRODUCT_STANDARD_SERVER () { 0x007 } # Server Standard (full installation) 192sub PRODUCT_DATACENTER_SERVER () { 0x008 } # Server Datacenter (full installation) 193sub PRODUCT_SMALLBUSINESS_SERVER () { 0x009 } # Windows Small Business Server 194sub PRODUCT_ENTERPRISE_SERVER () { 0x00A } # Server Enterprise (full installation) 195sub PRODUCT_STARTER () { 0x00B } # Starter 196sub PRODUCT_DATACENTER_SERVER_CORE () { 0x00C } # Server Datacenter (core installation) 197sub PRODUCT_STANDARD_SERVER_CORE () { 0x00D } # Server Standard (core installation) 198sub PRODUCT_ENTERPRISE_SERVER_CORE () { 0x00E } # Server Enterprise (core installation) 199sub PRODUCT_ENTERPRISE_SERVER_IA64 () { 0x00F } # Server Enterprise for Itanium-based Systems 200sub PRODUCT_BUSINESS_N () { 0x010 } # Business N 201sub PRODUCT_WEB_SERVER () { 0x011 } # Web Server (full installation) 202sub PRODUCT_CLUSTER_SERVER () { 0x012 } # HPC Edition 203sub PRODUCT_HOME_SERVER () { 0x013 } # Home Server Edition 204sub PRODUCT_STORAGE_EXPRESS_SERVER () { 0x014 } # Storage Server Express 205sub PRODUCT_STORAGE_STANDARD_SERVER () { 0x015 } # Storage Server Standard 206sub PRODUCT_STORAGE_WORKGROUP_SERVER () { 0x016 } # Storage Server Workgroup 207sub PRODUCT_STORAGE_ENTERPRISE_SERVER () { 0x017 } # Storage Server Enterprise 208sub PRODUCT_SERVER_FOR_SMALLBUSINESS () { 0x018 } # Windows Server 2008 for Windows Essential Server Solutions 209sub PRODUCT_SMALLBUSINESS_SERVER_PREMIUM () { 0x019 } # Windows Small Business Server Premium 210sub PRODUCT_HOME_PREMIUM_N () { 0x01A } # Home Premium N 211sub PRODUCT_ENTERPRISE_N () { 0x01B } # Enterprise N 212sub PRODUCT_ULTIMATE_N () { 0x01C } # Ultimate N 213sub PRODUCT_WEB_SERVER_CORE () { 0x01D } # Web Server (core installation) 214sub PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT () { 0x01E } # Windows Essential Business Server Management Server 215sub PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY () { 0x01F } # Windows Essential Business Server Security Server 216sub PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING () { 0x020 } # Windows Essential Business Server Messaging Server 217sub PRODUCT_SERVER_FOUNDATION () { 0x021 } # Server Foundation 218 219sub PRODUCT_SERVER_FOR_SMALLBUSINESS_V () { 0x023 } # Windows Server 2008 without Hyper-V for Windows Essential Server Solutions 220sub PRODUCT_STANDARD_SERVER_V () { 0x024 } # Server Standard without Hyper-V (full installation) 221sub PRODUCT_DATACENTER_SERVER_V () { 0x025 } # Server Datacenter without Hyper-V (full installation) 222sub PRODUCT_ENTERPRISE_SERVER_V () { 0x026 } # Server Enterprise without Hyper-V (full installation) 223sub PRODUCT_DATACENTER_SERVER_CORE_V () { 0x027 } # Server Datacenter without Hyper-V (core installation) 224sub PRODUCT_STANDARD_SERVER_CORE_V () { 0x028 } # Server Standard without Hyper-V (core installation) 225sub PRODUCT_ENTERPRISE_SERVER_CORE_V () { 0x029 } # Server Enterprise without Hyper-V (core installation) 226sub PRODUCT_HYPERV () { 0x02A } # Microsoft Hyper-V Server 227 228sub PRODUCT_STARTER_N () { 0x02F } # Starter N 229sub PRODUCT_PROFESSIONAL () { 0x030 } # Professional 230sub PRODUCT_PROFESSIONAL_N () { 0x031 } # Professional N 231 232sub PRODUCT_STARTER_E () { 0x042 } # Starter E 233sub PRODUCT_HOME_BASIC_E () { 0x043 } # Home Basic E 234sub PRODUCT_HOME_PREMIUM_E () { 0x044 } # Home Premium E 235sub PRODUCT_PROFESSIONAL_E () { 0x045 } # Professional E 236sub PRODUCT_ENTERPRISE_E () { 0x046 } # Enterprise E 237sub PRODUCT_ULTIMATE_E () { 0x047 } # Ultimate E 238 239sub PRODUCT_UNLICENSED () { 0xABCDABCD } # product has not been activated and is no longer in the grace period 240 241sub PROCESSOR_ARCHITECTURE_AMD64 () { 9 } # x64 (AMD or Intel) 242sub PROCESSOR_ARCHITECTURE_IA64 () { 6 } # Intel Itanium Processor Family (IPF) 243sub PROCESSOR_ARCHITECTURE_INTEL () { 0 } # x86 244sub PROCESSOR_ARCHITECTURE_UNKNOWN () { 0xffff } # Unknown architecture. 245 246sub _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 260my ($cached_os, $cached_desc); 261 262sub 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 274sub 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 302sub _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 310sub _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 568local $^W = 0; 569bootstrap Win32; 570 5711; 572 573__END__ 574 575=head1 NAME 576 577Win32 - Interfaces to some Win32 API Functions 578 579=head1 DESCRIPTION 580 581The Win32 module contains functions to access Win32 APIs. 582 583=head2 Alphabetical Listing of Win32 Functions 584 585It is recommended to C<use Win32;> before any of these functions; 586however, for backwards compatibility, those marked as [CORE] will 587automatically do this for you. 588 589In the function descriptions below the term I<Unicode string> is used 590to indicate that the string may contain characters outside the system 591codepage. The caveat I<If supported by the core Perl version> 592generally means Perl 5.8.9 and later, though some Unicode pathname 593functionality may work on earlier versions. 594 595=over 596 597=item Win32::AbortSystemShutdown(MACHINE) 598 599Aborts a system shutdown (started by the 600InitiateSystemShutdown function) on the specified MACHINE. 601 602=item Win32::BuildNumber() 603 604[CORE] Returns the ActivePerl build number. This function is 605only 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 610file. All file information like creation time and file attributes will 611be copied to the new file. However it will B<not> copy the security 612information. If the destination file already exists it will only be 613overwritten when the OVERWRITE parameter is true. But even this will 614not overwrite a read-only file; you have to unlink() it first 615yourself. 616 617=item Win32::CreateDirectory(DIRECTORY) 618 619Creates the DIRECTORY and returns a true value on success. Check $^E 620on failure for extended error information. 621 622DIRECTORY may contain Unicode characters outside the system codepage. 623Once the directory has been created you can use 624Win32::GetANSIPathName() to get a name that can be passed to system 625calls and external programs. 626 627=item Win32::CreateFile(FILE) 628 629Creates the FILE and returns a true value on success. Check $^E on 630failure for extended error information. 631 632FILE may contain Unicode characters outside the system codepage. Once 633the file has been created you can use Win32::GetANSIPathName() to get 634a 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 639that the owner of the current perl process is logged into. The 640"Workstation" service must be running to determine this 641information. This function does B<not> work on Windows 9x. 642 643=item Win32::ExpandEnvironmentStrings(STRING) 644 645Takes STRING and replaces all referenced environment variable 646names with their defined values. References to environment variables 647take the form C<%VariableName%>. Case is ignored when looking up the 648VariableName in the environment. If the variable is not found then the 649original C<%VariableName%> text is retained. Has the same effect 650as the following: 651 652 $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg 653 654However, this function may return a Unicode string if the environment 655variable being expanded hasn't been assigned to via %ENV. Access 656to %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 661Win32::GetLastError()) to a descriptive string. Analogous to the 662perror() standard-C library function. Note that C<$^E> used 663in 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 671drive (like 'FAT' or 'NTFS'). In list context it returns three values: 672(FSTYPE, FLAGS, MAXCOMPLEN). FSTYPE is the filesystem type as 673before. 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 688MAXCOMPLEN is the maximum length of a filename component (the part 689between two backslashes) on this file system. 690 691=item Win32::FreeLibrary(HANDLE) 692 693Unloads a previously loaded dynamic-link library. The HANDLE is 694no longer valid after this call. See L<LoadLibrary|Win32::LoadLibrary(LIBNAME)> 695for information on dynamically loading a library. 696 697=item Win32::GetACP() 698 699Returns the current Windows ANSI code page identifier for the operating 700system. See also GetOEMCP(), GetConsoleCP() and GetConsoleOutputCP(). 701 702=item Win32::GetANSIPathName(FILENAME) 703 704Returns an ANSI version of FILENAME. This may be the short name 705if the long name cannot be represented in the system codepage. 706 707While not currently implemented, it is possible that in the future 708this function will convert only parts of the path to FILENAME to a 709short form. 710 711If FILENAME doesn't exist on the filesystem, or if the filesystem 712doesn't support short ANSI filenames, then this function will 713translate the Unicode name into the system codepage using replacement 714characters. 715 716=item Win32::GetArchName() 717 718Use 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 723Returns the processor type: 386, 486 or 586 for x86 processors, 8664 724for the x64 processor and 2200 for the Itanium. Since it returns the 725native processor type it will return a 64-bit processor type even when 726called from a 32-bit Perl running on 64-bit Windows. 727 728=item Win32::GetConsoleCP() 729 730Returns the input code page used by the console associated with the 731calling process. To set the console's input code page, see 732SetConsoleCP(). See also GetConsoleOutputCP(), GetACP() and 733GetOEMCP(). 734 735=item Win32::GetConsoleOutputCP() 736 737Returns the output code page used by the console associated with the 738calling process. To set the console's output code page, see 739SetConsoleOutputCP(). See also GetConsoleCP(), GetACP(), and 740GetOEMCP(). 741 742=item Win32::GetCwd() 743 744[CORE] Returns the current active drive and directory. This function 745does not return a UNC path, since the functionality required for such 746a feature is not available under Windows 95. 747 748If supported by the core Perl version, this function will return an 749ANSI path name for the current directory if the long pathname cannot 750be represented in the system codepage. 751 752=item Win32::GetCurrentProcessId() 753 754Returns the process identifier of the current process. Until the 755process terminates, the process identifier uniquely identifies the 756process throughout the system. 757 758The current process identifier is normally also available via the 759predefined $$ variable. Under fork() emulation however $$ may contain 760a pseudo-process identifier that is only meaningful to the Perl 761kill(), wait() and waitpid() functions. The 762Win32::GetCurrentProcessId() function will always return the regular 763Windows process id, even when called from inside a pseudo-process. 764 765=item Win32::GetCurrentThreadId() 766 767Returns the thread identifier of the calling thread. Until the thread 768terminates, the thread identifier uniquely identifies the thread 769throughout the system. 770 771=item Win32::GetFileVersion(FILENAME) 772 773Returns the file version number from the VERSIONINFO resource of 774the executable file or DLL. This is a tuple of four 16 bit numbers. 775In list context these four numbers will be returned. In scalar context 776they are concatenated into a string, separated by dots. 777 778=item Win32::GetFolderPath(FOLDER [, CREATE]) 779 780Returns the full pathname of one of the Windows special folders. 781The folder will be created if it doesn't exist and the optional CREATE 782argument is true. The following FOLDER constants are defined by the 783Win32 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 828Note that not all folders are defined on all versions of Windows. 829 830Please refer to the MSDN documentation of the CSIDL constants, 831currently available at: 832 833http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp 834 835This function will return an ANSI folder path if the long name cannot 836be represented in the system codepage. Use Win32::GetLongPathName() 837on the result of Win32::GetFolderPath() if you want the Unicode 838version of the folder name. 839 840=item Win32::GetFullPathName(FILENAME) 841 842[CORE] GetFullPathName combines the FILENAME with the current drive 843and directory name and returns a fully qualified (aka, absolute) 844path name. In list context it returns two elements: (PATH, FILE) where 845PATH is the complete pathname component (including trailing backslash) 846and FILE is just the filename part. Note that no attempt is made to 847convert 8.3 components in the supplied FILENAME to longnames or 848vice-versa. Compare with Win32::GetShortPathName() and 849Win32::GetLongPathName(). 850 851If supported by the core Perl version, this function will return an 852ANSI path name if the full pathname cannot be represented in the 853system codepage. 854 855=item Win32::GetLastError() 856 857[CORE] Returns the last error value generated by a call to a Win32 API 858function. Note that C<$^E> used in a numeric context amounts to the 859same value. 860 861=item Win32::GetLongPathName(PATHNAME) 862 863[CORE] Returns a representation of PATHNAME composed of longname 864components (if any). The result may not necessarily be longer 865than PATHNAME. No attempt is made to convert PATHNAME to the 866absolute path. Compare with Win32::GetShortPathName() and 867Win32::GetFullPathName(). 868 869This function may return the pathname in Unicode if it cannot be 870represented in the system codepage. Use Win32::GetANSIPathName() 871before 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 876available drive letter. 877 878=item Win32::GetOEMCP() 879 880Returns the current original equipment manufacturer (OEM) code page 881identifier for the operating system. See also GetACP(), GetConsoleCP() 882and GetConsoleOutputCP(). 883 884=item Win32::GetOSDisplayName() 885 886Returns the "marketing" name of the Windows operating system version 887being 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 897The display name describes the native Windows version, so even on a 89832-bit Perl this function may return a "Windows ... (64-bit)" name 899when running on a 64-bit Windows. 900 901This function should only be used to display the actual OS name to the 902user; it should not be used to determine the class of operating systems 903this system belongs to. The Win32::GetOSName(), Win32::GetOSVersion, 904Win32::GetProductInfo() and Win32::GetSystemMetrics() functions provide 905the base information to check for certain capabilities, or for families 906of OS releases. 907 908=item Win32::GetOSName() 909 910In scalar context returns the name of the Win32 operating system 911being used. In list context returns a two element list of the OS name 912and whatever edition information is known about the particular build 913(for Win9X boxes) and whatever service packs have been installed. 914The latter is roughly equivalent to the first item returned by 915GetOSVersion() in list context. 916 917The description will also include tags for other special editions, 918like "R2", "Media Center", "Tablet PC", or "Starter Edition". 919 920Currently 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 936This routine is just a simple interface into GetOSVersion(). More 937specific or demanding situations should use that instead. Another 938option would be to use POSIX::uname(), however the latter appears to 939report only the OS family name and not the specific OS. In scalar 940context it returns just the ID. 941 942The name "WinXP/.Net" is used for historical reasons only, to maintain 943backwards compatibility of the Win32 module. Windows .NET Server has 944been renamed as Windows 2003 Server before final release and uses a 945different major/minor version number than Windows XP. 946 947Similarly the name "WinWin32s" should have been "Win32s" but has been 948kept 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 953elements are, respectively: An arbitrary descriptive string, the major 954version number of the operating system, the minor version number, the 955build number, and a digit indicating the actual operating system. 956For the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for 957Windows NT/2000/XP/2003/Vista/2008/7. In scalar context it returns just 958the ID. 959 960Currently 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 984On Windows NT 4 SP6 and later this function returns the following 985additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE. 986 987The version numbers for Windows 2003 and Windows Home Server are 988identical; the SUITEMASK field must be used to differentiate between 989them. 990 991The version numbers for Windows Vista and Windows Server 2008 are 992identical; the PRODUCTTYPE field must be used to differentiate between 993them. 994 995The version numbers for Windows 7 and Windows Server 2008 R2 are 996identical; the PRODUCTTYPE field must be used to differentiate between 997them. 998 999The version numbers for Windows 8 and Windows Server 2012 are 1000identical; the PRODUCTTYPE field must be used to differentiate between 1001them. 1002 1003SPMAJOR and SPMINOR are the version numbers of the latest 1004installed service pack. 1005 1006SUITEMASK is a bitfield identifying the product suites available on 1007the 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 1026The VER_SUITE_xxx names are listed here to cross reference the Microsoft 1027documentation. The Win32 module does not provide symbolic names for these 1028constants. 1029 1030PRODUCTTYPE provides additional information about the system. It should 1031be 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 1037Note that a server that is also a domain controller is reported as 1038PRODUCTTYPE 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 1044file system has not generated the short form the returned path will 1045use the long form, so this function might still for instance return a 1046path containing spaces. Returns C<undef> when the PATHNAME does not 1047exist. Compare with Win32::GetFullPathName() and 1048Win32::GetLongPathName(). 1049 1050=item Win32::GetSystemMetrics(INDEX) 1051 1052Retrieves the specified system metric or system configuration setting. 1053Please refer to the Microsoft documentation of the GetSystemMetrics() 1054function for a reference of available INDEX values. All system 1055metrics return integer values. 1056 1057=item Win32::GetProcAddress(INSTANCE, PROCNAME) 1058 1059Returns the address of a function inside a loaded library. The 1060information about what you can do with this address has been lost in 1061the mist of time. Use the Win32::API module instead of this deprecated 1062function. 1063 1064=item Win32::GetProductInfo(OSMAJOR, OSMINOR, SPMAJOR, SPMINOR) 1065 1066Retrieves the product type for the operating system on the local 1067computer, and maps the type to the product types supported by the 1068specified operating system. Please refer to the Microsoft 1069documentation of the GetProductInfo() function for more information 1070about the parameters and return value. This function requires Windows 1071Vista or later. 1072 1073See also the Win32::GetOSName() and Win32::GetOSDisplayName() 1074functions which provide a higher level abstraction of the data 1075returned by this function. 1076 1077=item Win32::GetTickCount() 1078 1079[CORE] Returns the number of milliseconds elapsed since the last 1080system boot. Resolution is limited to system timer ticks (about 10ms 1081on WinNT and 55ms on Win9X). 1082 1083=item Win32::GuidGen() 1084 1085Creates a globally unique 128 bit integer that can be used as a 1086persistent identifier in a distributed setting. To a very high degree 1087of certainty this function returns a unique value. No other 1088invocation, on the same or any other system (networked or not), should 1089return the same value. 1090 1091The return value is formatted according to OLE conventions, as groups 1092of 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 1100Shutsdown the specified MACHINE, notifying users with the 1101supplied MESSAGE, within the specified TIMEOUT interval. Forces 1102closing of all documents without prompting the user if FORCECLOSE is 1103true, and reboots the machine if REBOOT is true. This function works 1104only on WinNT. 1105 1106=item Win32::IsAdminUser() 1107 1108Returns non zero if the account in whose security context the 1109current process/thread is running belongs to the local group of 1110Administrators in the built-in system domain; returns 0 if not. 1111On Windows Vista it will only return non-zero if the process is 1112actually running with elevated privileges. Returns C<undef> 1113and prints a warning if an error occurred. This function always 1114returns 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 1126Loads a dynamic link library into memory and returns its module 1127handle. This handle can be used with Win32::GetProcAddress() and 1128Win32::FreeLibrary(). This function is deprecated. Use the Win32::API 1129module instead. 1130 1131=item Win32::LoginName() 1132 1133[CORE] Returns the username of the owner of the current perl process. 1134The return value may be a Unicode string. 1135 1136=item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE) 1137 1138Looks up ACCOUNT on SYSTEM and returns the domain name the SID and 1139the SID type. 1140 1141=item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE) 1142 1143Looks up SID on SYSTEM and returns the account name, domain name, 1144and the SID type. 1145 1146=item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]]) 1147 1148Create a dialog box containing MESSAGE. FLAGS specifies the 1149required 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 1163TITLE specifies an optional window title. The default is "Perl". 1164 1165The 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 1183Sends a string to the application or system debugger for display. 1184The function does nothing if there is no active debugger. 1185 1186Alternatively one can use the I<Debug Viewer> application to 1187watch the OutputDebugString() output: 1188 1189http://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx 1190 1191=item Win32::RegisterServer(LIBRARYNAME) 1192 1193Loads 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(). 1198By default system() will create a new console window for child 1199processes if Perl itself is not running from a console. Calling 1200SetChildShowWindow(0) will make these new console windows invisible. 1201Calling SetChildShowWindow() without arguments reverts system() to the 1202default behavior. The return value of SetChildShowWindow() is the 1203previous setting or C<undef>. 1204 1205The following symbolic constants for SHOWWINDOW are available 1206(but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL, 1207SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE. 1208 1209=item Win32::SetConsoleCP(ID) 1210 1211Sets the input code page used by the console associated with the 1212calling process. The return value of SetConsoleCP() is nonzero on 1213success or zero on failure. To get the console's input code page, see 1214GetConsoleCP(). 1215 1216=item Win32::SetConsoleOutputCP(ID) 1217 1218Sets the output code page used by the console associated with the 1219calling process. The return value of SetConsoleOutputCP() is nonzero on 1220success or zero on failure. To get the console's output code page, see 1221GetConsoleOutputCP(). 1222 1223=item Win32::SetCwd(NEWDIRECTORY) 1224 1225[CORE] Sets the current active drive and directory. This function does not 1226work with UNC paths, since the functionality required to required for 1227such 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 1232that value that will be returned by the Win32::GetLastError() 1233function. 1234 1235=item Win32::Sleep(TIME) 1236 1237[CORE] Pauses for TIME milliseconds. The timeslices are made available 1238to 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 1243arguments in the string ARGS. The pid of the new process is stored in 1244PID. This function is deprecated. Please use the Win32::Process module 1245instead. 1246 1247=item Win32::UnregisterServer(LIBRARYNAME) 1248 1249Loads the DLL LIBRARYNAME and calls the function 1250DllUnregisterServer. 1251 1252=back 1253 1254=cut 1255