1b39c5158Smillertpackage Win32; 2b39c5158Smillert 3898184e3Ssthen# BEGIN { 4b39c5158Smillert use strict; 5b39c5158Smillert use vars qw|$VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK|; 6b39c5158Smillert 7b39c5158Smillert require Exporter; 8b39c5158Smillert require DynaLoader; 9b39c5158Smillert 10b39c5158Smillert @ISA = qw|Exporter DynaLoader|; 11*eac174f2Safresh1 $VERSION = '0.59'; 12b39c5158Smillert $XS_VERSION = $VERSION; 13b39c5158Smillert $VERSION = eval $VERSION; 14b39c5158Smillert 15b39c5158Smillert @EXPORT = qw( 16b39c5158Smillert NULL 17b39c5158Smillert WIN31_CLASS 18b39c5158Smillert OWNER_SECURITY_INFORMATION 19b39c5158Smillert GROUP_SECURITY_INFORMATION 20b39c5158Smillert DACL_SECURITY_INFORMATION 21b39c5158Smillert SACL_SECURITY_INFORMATION 22b39c5158Smillert MB_ICONHAND 23b39c5158Smillert MB_ICONQUESTION 24b39c5158Smillert MB_ICONEXCLAMATION 25b39c5158Smillert MB_ICONASTERISK 26b39c5158Smillert MB_ICONWARNING 27b39c5158Smillert MB_ICONERROR 28b39c5158Smillert MB_ICONINFORMATION 29b39c5158Smillert MB_ICONSTOP 30b39c5158Smillert ); 31b39c5158Smillert @EXPORT_OK = qw( 32b39c5158Smillert GetOSName 33b39c5158Smillert SW_HIDE 34b39c5158Smillert SW_SHOWNORMAL 35b39c5158Smillert SW_SHOWMINIMIZED 36b39c5158Smillert SW_SHOWMAXIMIZED 37b39c5158Smillert SW_SHOWNOACTIVATE 38b39c5158Smillert 39b39c5158Smillert CSIDL_DESKTOP 40b39c5158Smillert CSIDL_PROGRAMS 41b39c5158Smillert CSIDL_PERSONAL 42b39c5158Smillert CSIDL_FAVORITES 43b39c5158Smillert CSIDL_STARTUP 44b39c5158Smillert CSIDL_RECENT 45b39c5158Smillert CSIDL_SENDTO 46b39c5158Smillert CSIDL_STARTMENU 47b39c5158Smillert CSIDL_MYMUSIC 48b39c5158Smillert CSIDL_MYVIDEO 49b39c5158Smillert CSIDL_DESKTOPDIRECTORY 50b39c5158Smillert CSIDL_NETHOOD 51b39c5158Smillert CSIDL_FONTS 52b39c5158Smillert CSIDL_TEMPLATES 53b39c5158Smillert CSIDL_COMMON_STARTMENU 54b39c5158Smillert CSIDL_COMMON_PROGRAMS 55b39c5158Smillert CSIDL_COMMON_STARTUP 56b39c5158Smillert CSIDL_COMMON_DESKTOPDIRECTORY 57b39c5158Smillert CSIDL_APPDATA 58b39c5158Smillert CSIDL_PRINTHOOD 59b39c5158Smillert CSIDL_LOCAL_APPDATA 60b39c5158Smillert CSIDL_COMMON_FAVORITES 61b39c5158Smillert CSIDL_INTERNET_CACHE 62b39c5158Smillert CSIDL_COOKIES 63b39c5158Smillert CSIDL_HISTORY 64b39c5158Smillert CSIDL_COMMON_APPDATA 65b39c5158Smillert CSIDL_WINDOWS 66b39c5158Smillert CSIDL_SYSTEM 67b39c5158Smillert CSIDL_PROGRAM_FILES 68b39c5158Smillert CSIDL_MYPICTURES 69b39c5158Smillert CSIDL_PROFILE 70b39c5158Smillert CSIDL_PROGRAM_FILES_COMMON 71b39c5158Smillert CSIDL_COMMON_TEMPLATES 72b39c5158Smillert CSIDL_COMMON_DOCUMENTS 73b39c5158Smillert CSIDL_COMMON_ADMINTOOLS 74b39c5158Smillert CSIDL_ADMINTOOLS 75b39c5158Smillert CSIDL_COMMON_MUSIC 76b39c5158Smillert CSIDL_COMMON_PICTURES 77b39c5158Smillert CSIDL_COMMON_VIDEO 78b39c5158Smillert CSIDL_RESOURCES 79b39c5158Smillert CSIDL_RESOURCES_LOCALIZED 80b39c5158Smillert CSIDL_CDBURN_AREA 81b39c5158Smillert ); 82898184e3Ssthen# } 83b39c5158Smillert 84b39c5158Smillert# We won't bother with the constant stuff, too much of a hassle. Just hard 85b39c5158Smillert# code it here. 86b39c5158Smillert 87b39c5158Smillertsub NULL { 0 } 88b39c5158Smillertsub WIN31_CLASS { &NULL } 89b39c5158Smillert 90b39c5158Smillertsub OWNER_SECURITY_INFORMATION { 0x00000001 } 91b39c5158Smillertsub GROUP_SECURITY_INFORMATION { 0x00000002 } 92b39c5158Smillertsub DACL_SECURITY_INFORMATION { 0x00000004 } 93b39c5158Smillertsub SACL_SECURITY_INFORMATION { 0x00000008 } 94b39c5158Smillert 95b39c5158Smillertsub MB_ICONHAND { 0x00000010 } 96b39c5158Smillertsub MB_ICONQUESTION { 0x00000020 } 97b39c5158Smillertsub MB_ICONEXCLAMATION { 0x00000030 } 98b39c5158Smillertsub MB_ICONASTERISK { 0x00000040 } 99b39c5158Smillertsub MB_ICONWARNING { 0x00000030 } 100b39c5158Smillertsub MB_ICONERROR { 0x00000010 } 101b39c5158Smillertsub MB_ICONINFORMATION { 0x00000040 } 102b39c5158Smillertsub MB_ICONSTOP { 0x00000010 } 103b39c5158Smillert 104b39c5158Smillert# 105b39c5158Smillert# Newly added constants. These have an empty prototype, unlike the 106b39c5158Smillert# the ones above, which aren't prototyped for compatibility reasons. 107b39c5158Smillert# 108b39c5158Smillertsub SW_HIDE () { 0 } 109b39c5158Smillertsub SW_SHOWNORMAL () { 1 } 110b39c5158Smillertsub SW_SHOWMINIMIZED () { 2 } 111b39c5158Smillertsub SW_SHOWMAXIMIZED () { 3 } 112b39c5158Smillertsub SW_SHOWNOACTIVATE () { 4 } 113b39c5158Smillert 114b39c5158Smillertsub CSIDL_DESKTOP () { 0x0000 } # <desktop> 115b39c5158Smillertsub CSIDL_PROGRAMS () { 0x0002 } # Start Menu\Programs 116b39c5158Smillertsub CSIDL_PERSONAL () { 0x0005 } # "My Documents" folder 117b39c5158Smillertsub CSIDL_FAVORITES () { 0x0006 } # <user name>\Favorites 118b39c5158Smillertsub CSIDL_STARTUP () { 0x0007 } # Start Menu\Programs\Startup 119b39c5158Smillertsub CSIDL_RECENT () { 0x0008 } # <user name>\Recent 120b39c5158Smillertsub CSIDL_SENDTO () { 0x0009 } # <user name>\SendTo 121b39c5158Smillertsub CSIDL_STARTMENU () { 0x000B } # <user name>\Start Menu 122b39c5158Smillertsub CSIDL_MYMUSIC () { 0x000D } # "My Music" folder 123b39c5158Smillertsub CSIDL_MYVIDEO () { 0x000E } # "My Videos" folder 124b39c5158Smillertsub CSIDL_DESKTOPDIRECTORY () { 0x0010 } # <user name>\Desktop 125b39c5158Smillertsub CSIDL_NETHOOD () { 0x0013 } # <user name>\nethood 126b39c5158Smillertsub CSIDL_FONTS () { 0x0014 } # windows\fonts 127b39c5158Smillertsub CSIDL_TEMPLATES () { 0x0015 } 128b39c5158Smillertsub CSIDL_COMMON_STARTMENU () { 0x0016 } # All Users\Start Menu 129b39c5158Smillertsub CSIDL_COMMON_PROGRAMS () { 0x0017 } # All Users\Start Menu\Programs 130b39c5158Smillertsub CSIDL_COMMON_STARTUP () { 0x0018 } # All Users\Startup 131b39c5158Smillertsub CSIDL_COMMON_DESKTOPDIRECTORY () { 0x0019 } # All Users\Desktop 132b39c5158Smillertsub CSIDL_APPDATA () { 0x001A } # Application Data, new for NT4 133b39c5158Smillertsub CSIDL_PRINTHOOD () { 0x001B } # <user name>\PrintHood 134b39c5158Smillertsub CSIDL_LOCAL_APPDATA () { 0x001C } # non roaming, user\Local Settings\Application Data 135b39c5158Smillertsub CSIDL_COMMON_FAVORITES () { 0x001F } 136b39c5158Smillertsub CSIDL_INTERNET_CACHE () { 0x0020 } 137b39c5158Smillertsub CSIDL_COOKIES () { 0x0021 } 138b39c5158Smillertsub CSIDL_HISTORY () { 0x0022 } 139b39c5158Smillertsub CSIDL_COMMON_APPDATA () { 0x0023 } # All Users\Application Data 140b39c5158Smillertsub CSIDL_WINDOWS () { 0x0024 } # GetWindowsDirectory() 141b39c5158Smillertsub CSIDL_SYSTEM () { 0x0025 } # GetSystemDirectory() 142b39c5158Smillertsub CSIDL_PROGRAM_FILES () { 0x0026 } # C:\Program Files 143b39c5158Smillertsub CSIDL_MYPICTURES () { 0x0027 } # "My Pictures", new for Win2K 144b39c5158Smillertsub CSIDL_PROFILE () { 0x0028 } # USERPROFILE 145b39c5158Smillertsub CSIDL_PROGRAM_FILES_COMMON () { 0x002B } # C:\Program Files\Common 146b39c5158Smillertsub CSIDL_COMMON_TEMPLATES () { 0x002D } # All Users\Templates 147b39c5158Smillertsub CSIDL_COMMON_DOCUMENTS () { 0x002E } # All Users\Documents 148b39c5158Smillertsub CSIDL_COMMON_ADMINTOOLS () { 0x002F } # All Users\Start Menu\Programs\Administrative Tools 149b39c5158Smillertsub CSIDL_ADMINTOOLS () { 0x0030 } # <user name>\Start Menu\Programs\Administrative Tools 150b39c5158Smillertsub CSIDL_COMMON_MUSIC () { 0x0035 } # All Users\My Music 151b39c5158Smillertsub CSIDL_COMMON_PICTURES () { 0x0036 } # All Users\My Pictures 152b39c5158Smillertsub CSIDL_COMMON_VIDEO () { 0x0037 } # All Users\My Video 153b39c5158Smillertsub CSIDL_RESOURCES () { 0x0038 } # %windir%\Resources\, For theme and other windows resources. 154b39c5158Smillertsub CSIDL_RESOURCES_LOCALIZED () { 0x0039 } # %windir%\Resources\<LangID>, for theme and other windows specific resources. 155b39c5158Smillertsub CSIDL_CDBURN_AREA () { 0x003B } # <user name>\Local Settings\Application Data\Microsoft\CD Burning 156b39c5158Smillert 157898184e3Ssthensub 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. 158898184e3Ssthensub VER_NT_SERVER () { 0x0000003 } # The operating system is Windows Server 2008, Windows Server 2003, or Windows 2000 Server. 159898184e3Ssthen# Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER. 160898184e3Ssthensub VER_NT_WORKSTATION () { 0x0000001 } # The operating system is Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional. 161898184e3Ssthen 162898184e3Ssthen 163898184e3Ssthensub VER_SUITE_BACKOFFICE () { 0x00000004 } # Microsoft BackOffice components are installed. 164898184e3Ssthensub VER_SUITE_BLADE () { 0x00000400 } # Windows Server 2003, Web Edition is installed. 165898184e3Ssthensub VER_SUITE_COMPUTE_SERVER () { 0x00004000 } # Windows Server 2003, Compute Cluster Edition is installed. 166898184e3Ssthensub VER_SUITE_DATACENTER () { 0x00000080 } # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed. 167898184e3Ssthensub 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. 168898184e3Ssthensub VER_SUITE_EMBEDDEDNT () { 0x00000040 } # Windows XP Embedded is installed. 169898184e3Ssthensub VER_SUITE_PERSONAL () { 0x00000200 } # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed. 170898184e3Ssthensub 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. 171898184e3Ssthensub 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. 172898184e3Ssthensub 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. 173898184e3Ssthensub VER_SUITE_STORAGE_SERVER () { 0x00002000 } # Windows Storage Server 2003 R2 or Windows Storage Server 2003 is installed. 174898184e3Ssthensub VER_SUITE_TERMINAL () { 0x00000010 } # Terminal Services is installed. This value is always set. 175898184e3Ssthen# If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode. 176898184e3Ssthensub VER_SUITE_WH_SERVER () { 0x00008000 } # Windows Home Server is installed. 177*eac174f2Safresh1sub VER_SUITE_MULTIUSERTS () { 0x00020000 } # AppServer mode is enabled. 178898184e3Ssthen 179898184e3Ssthen 180898184e3Ssthensub SM_TABLETPC () { 86 } 181898184e3Ssthensub SM_MEDIACENTER () { 87 } 182898184e3Ssthensub SM_STARTER () { 88 } 183898184e3Ssthensub SM_SERVERR2 () { 89 } 184898184e3Ssthen 185898184e3Ssthensub PRODUCT_UNDEFINED () { 0x000 } # An unknown product 186898184e3Ssthensub PRODUCT_ULTIMATE () { 0x001 } # Ultimate 187898184e3Ssthensub PRODUCT_HOME_BASIC () { 0x002 } # Home Basic 188898184e3Ssthensub PRODUCT_HOME_PREMIUM () { 0x003 } # Home Premium 189898184e3Ssthensub PRODUCT_ENTERPRISE () { 0x004 } # Enterprise 190898184e3Ssthensub PRODUCT_HOME_BASIC_N () { 0x005 } # Home Basic N 191898184e3Ssthensub PRODUCT_BUSINESS () { 0x006 } # Business 192898184e3Ssthensub PRODUCT_STANDARD_SERVER () { 0x007 } # Server Standard (full installation) 193898184e3Ssthensub PRODUCT_DATACENTER_SERVER () { 0x008 } # Server Datacenter (full installation) 194898184e3Ssthensub PRODUCT_SMALLBUSINESS_SERVER () { 0x009 } # Windows Small Business Server 195898184e3Ssthensub PRODUCT_ENTERPRISE_SERVER () { 0x00A } # Server Enterprise (full installation) 196898184e3Ssthensub PRODUCT_STARTER () { 0x00B } # Starter 197898184e3Ssthensub PRODUCT_DATACENTER_SERVER_CORE () { 0x00C } # Server Datacenter (core installation) 198898184e3Ssthensub PRODUCT_STANDARD_SERVER_CORE () { 0x00D } # Server Standard (core installation) 199898184e3Ssthensub PRODUCT_ENTERPRISE_SERVER_CORE () { 0x00E } # Server Enterprise (core installation) 200898184e3Ssthensub PRODUCT_ENTERPRISE_SERVER_IA64 () { 0x00F } # Server Enterprise for Itanium-based Systems 201898184e3Ssthensub PRODUCT_BUSINESS_N () { 0x010 } # Business N 202898184e3Ssthensub PRODUCT_WEB_SERVER () { 0x011 } # Web Server (full installation) 203898184e3Ssthensub PRODUCT_CLUSTER_SERVER () { 0x012 } # HPC Edition 204898184e3Ssthensub PRODUCT_HOME_SERVER () { 0x013 } # Home Server Edition 205898184e3Ssthensub PRODUCT_STORAGE_EXPRESS_SERVER () { 0x014 } # Storage Server Express 206898184e3Ssthensub PRODUCT_STORAGE_STANDARD_SERVER () { 0x015 } # Storage Server Standard 207898184e3Ssthensub PRODUCT_STORAGE_WORKGROUP_SERVER () { 0x016 } # Storage Server Workgroup 208898184e3Ssthensub PRODUCT_STORAGE_ENTERPRISE_SERVER () { 0x017 } # Storage Server Enterprise 209898184e3Ssthensub PRODUCT_SERVER_FOR_SMALLBUSINESS () { 0x018 } # Windows Server 2008 for Windows Essential Server Solutions 210898184e3Ssthensub PRODUCT_SMALLBUSINESS_SERVER_PREMIUM () { 0x019 } # Windows Small Business Server Premium 211898184e3Ssthensub PRODUCT_HOME_PREMIUM_N () { 0x01A } # Home Premium N 212898184e3Ssthensub PRODUCT_ENTERPRISE_N () { 0x01B } # Enterprise N 213898184e3Ssthensub PRODUCT_ULTIMATE_N () { 0x01C } # Ultimate N 214898184e3Ssthensub PRODUCT_WEB_SERVER_CORE () { 0x01D } # Web Server (core installation) 215898184e3Ssthensub PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT () { 0x01E } # Windows Essential Business Server Management Server 216898184e3Ssthensub PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY () { 0x01F } # Windows Essential Business Server Security Server 217898184e3Ssthensub PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING () { 0x020 } # Windows Essential Business Server Messaging Server 218898184e3Ssthensub PRODUCT_SERVER_FOUNDATION () { 0x021 } # Server Foundation 219b8851fccSafresh1#define PRODUCT_HOME_PREMIUM_SERVER 0x00000022 220898184e3Ssthensub PRODUCT_SERVER_FOR_SMALLBUSINESS_V () { 0x023 } # Windows Server 2008 without Hyper-V for Windows Essential Server Solutions 221898184e3Ssthensub PRODUCT_STANDARD_SERVER_V () { 0x024 } # Server Standard without Hyper-V (full installation) 222898184e3Ssthensub PRODUCT_DATACENTER_SERVER_V () { 0x025 } # Server Datacenter without Hyper-V (full installation) 223898184e3Ssthensub PRODUCT_ENTERPRISE_SERVER_V () { 0x026 } # Server Enterprise without Hyper-V (full installation) 224898184e3Ssthensub PRODUCT_DATACENTER_SERVER_CORE_V () { 0x027 } # Server Datacenter without Hyper-V (core installation) 225898184e3Ssthensub PRODUCT_STANDARD_SERVER_CORE_V () { 0x028 } # Server Standard without Hyper-V (core installation) 226898184e3Ssthensub PRODUCT_ENTERPRISE_SERVER_CORE_V () { 0x029 } # Server Enterprise without Hyper-V (core installation) 227898184e3Ssthensub PRODUCT_HYPERV () { 0x02A } # Microsoft Hyper-V Server 228b8851fccSafresh1#define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B 229b8851fccSafresh1#define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C 230b8851fccSafresh1#define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D 231b8851fccSafresh1#define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E 232898184e3Ssthensub PRODUCT_STARTER_N () { 0x02F } # Starter N 233898184e3Ssthensub PRODUCT_PROFESSIONAL () { 0x030 } # Professional 234898184e3Ssthensub PRODUCT_PROFESSIONAL_N () { 0x031 } # Professional N 235b8851fccSafresh1#define PRODUCT_SB_SOLUTION_SERVER 0x00000032 236b8851fccSafresh1#define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033 237b8851fccSafresh1#define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034 238b8851fccSafresh1#define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035 239b8851fccSafresh1#define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036 240b8851fccSafresh1#define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037 241b8851fccSafresh1#define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038 242b8851fccSafresh1#define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039 243b8851fccSafresh1#define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A 244b8851fccSafresh1#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B 245b8851fccSafresh1#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C 246b8851fccSafresh1#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D 247b8851fccSafresh1#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E 248b8851fccSafresh1#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F 249b8851fccSafresh1#define PRODUCT_CLUSTER_SERVER_V 0x00000040 250b8851fccSafresh1#define PRODUCT_EMBEDDED 0x00000041 251898184e3Ssthensub PRODUCT_STARTER_E () { 0x042 } # Starter E 252898184e3Ssthensub PRODUCT_HOME_BASIC_E () { 0x043 } # Home Basic E 253898184e3Ssthensub PRODUCT_HOME_PREMIUM_E () { 0x044 } # Home Premium E 254898184e3Ssthensub PRODUCT_PROFESSIONAL_E () { 0x045 } # Professional E 255898184e3Ssthensub PRODUCT_ENTERPRISE_E () { 0x046 } # Enterprise E 256898184e3Ssthensub PRODUCT_ULTIMATE_E () { 0x047 } # Ultimate E 257b8851fccSafresh1#define PRODUCT_ENTERPRISE_EVALUATION 0x00000048 258b8851fccSafresh1#define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C 259b8851fccSafresh1#define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D 260b8851fccSafresh1#define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F 261b8851fccSafresh1#define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050 262b8851fccSafresh1#define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054 263b8851fccSafresh1#define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055 264b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056 265b8851fccSafresh1#define PRODUCT_THINPC 0x00000057 266b8851fccSafresh1#define PRODUCT_EMBEDDED_A 0x00000058 267b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY 0x00000059 268b8851fccSafresh1#define PRODUCT_EMBEDDED_E 0x0000005A 269b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B 270b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C 271b8851fccSafresh1#define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F 272b8851fccSafresh1#define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060 273b8851fccSafresh1#define PRODUCT_CORE_ARM 0x00000061 274b8851fccSafresh1sub PRODUCT_CORE_N () { 0x62 } # Windows 10 Home N 275b8851fccSafresh1sub PRODUCT_CORE_COUNTRYSPECIFIC () { 0x63 } # Windows 10 Home China 276b8851fccSafresh1sub PRODUCT_CORE_SINGLELANGUAGE () { 0x64 } # Windows 10 Home Single Language 277b8851fccSafresh1sub PRODUCT_CORE () { 0x65 } # Windows 10 Home 278b8851fccSafresh1#define PRODUCT_PROFESSIONAL_WMC 0x00000067 279b8851fccSafresh1#define PRODUCT_MOBILE_CORE 0x00000068 280b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069 281b8851fccSafresh1#define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A 282b8851fccSafresh1#define PRODUCT_EMBEDDED_EVAL 0x0000006B 283b8851fccSafresh1#define PRODUCT_EMBEDDED_E_EVAL 0x0000006C 284b8851fccSafresh1#define PRODUCT_NANO_SERVER 0x0000006D 285b8851fccSafresh1#define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E 286b8851fccSafresh1#define PRODUCT_CORE_CONNECTED 0x0000006F 287b8851fccSafresh1#define PRODUCT_PROFESSIONAL_STUDENT 0x00000070 288b8851fccSafresh1#define PRODUCT_CORE_CONNECTED_N 0x00000071 289b8851fccSafresh1#define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072 290b8851fccSafresh1#define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073 291b8851fccSafresh1#define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074 292b8851fccSafresh1#define PRODUCT_CONNECTED_CAR 0x00000075 293b8851fccSafresh1#define PRODUCT_INDUSTRY_HANDHELD 0x00000076 294b8851fccSafresh1#define PRODUCT_PPI_PRO 0x00000077 295b8851fccSafresh1#define PRODUCT_ARM64_SERVER 0x00000078 296b8851fccSafresh1sub PRODUCT_EDUCATION () { 0x79 } # Windows 10 Education 297b8851fccSafresh1sub PRODUCT_EDUCATION_N () { 0x7A } # Windows 10 Education N 298b8851fccSafresh1#define PRODUCT_IOTUAP 0x0000007B 299b8851fccSafresh1#define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C 300b8851fccSafresh1#define PRODUCT_ENTERPRISE_S 0x0000007D 301b8851fccSafresh1#define PRODUCT_ENTERPRISE_S_N 0x0000007E 302b8851fccSafresh1#define PRODUCT_PROFESSIONAL_S 0x0000007F 303b8851fccSafresh1#define PRODUCT_PROFESSIONAL_S_N 0x00000080 304b8851fccSafresh1#define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081 305b8851fccSafresh1#define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082 306898184e3Ssthen 307898184e3Ssthensub PRODUCT_UNLICENSED () { 0xABCDABCD } # product has not been activated and is no longer in the grace period 308898184e3Ssthen 309*eac174f2Safresh1sub PROCESSOR_ARCHITECTURE_ARM64 () { 12 } # ARM64 310*eac174f2Safresh1sub PROCESSOR_ARCHITECTURE_ARM () { 5 } # ARM 311898184e3Ssthensub PROCESSOR_ARCHITECTURE_AMD64 () { 9 } # x64 (AMD or Intel) 312898184e3Ssthensub PROCESSOR_ARCHITECTURE_IA64 () { 6 } # Intel Itanium Processor Family (IPF) 313898184e3Ssthensub PROCESSOR_ARCHITECTURE_INTEL () { 0 } # x86 314898184e3Ssthensub PROCESSOR_ARCHITECTURE_UNKNOWN () { 0xffff } # Unknown architecture. 315898184e3Ssthen 316898184e3Ssthensub _GetProcessorArchitecture { 317898184e3Ssthen my $arch = { 318898184e3Ssthen 386 => PROCESSOR_ARCHITECTURE_INTEL, 319898184e3Ssthen 486 => PROCESSOR_ARCHITECTURE_INTEL, 320898184e3Ssthen 586 => PROCESSOR_ARCHITECTURE_INTEL, 321898184e3Ssthen 2200 => PROCESSOR_ARCHITECTURE_IA64, 322898184e3Ssthen 8664 => PROCESSOR_ARCHITECTURE_AMD64, 323898184e3Ssthen }->{Win32::GetChipName()}; 324*eac174f2Safresh1 325*eac174f2Safresh1 if (!defined($arch)) { 326*eac174f2Safresh1 $arch = { 327*eac174f2Safresh1 5 => PROCESSOR_ARCHITECTURE_ARM, 328*eac174f2Safresh1 12 => PROCESSOR_ARCHITECTURE_ARM64, 329*eac174f2Safresh1 }->{Win32::GetChipArch()}; 330*eac174f2Safresh1 } 331*eac174f2Safresh1 332898184e3Ssthen return defined($arch) ? $arch : PROCESSOR_ARCHITECTURE_UNKNOWN; 333898184e3Ssthen} 334898184e3Ssthen 335b39c5158Smillert### This method is just a simple interface into GetOSVersion(). More 336b39c5158Smillert### specific or demanding situations should use that instead. 337b39c5158Smillert 338b39c5158Smillertmy ($cached_os, $cached_desc); 339b39c5158Smillert 340b39c5158Smillertsub GetOSName { 341b39c5158Smillert unless (defined $cached_os) { 342898184e3Ssthen my($desc, $major, $minor, $build, $id, undef, undef, $suitemask, $producttype) 343b39c5158Smillert = Win32::GetOSVersion(); 344898184e3Ssthen my $arch = _GetProcessorArchitecture(); 345898184e3Ssthen my $productinfo = Win32::GetProductInfo(6, 0, 0, 0); 346898184e3Ssthen ($cached_os, $cached_desc) = _GetOSName($desc, $major, $minor, $build, $id, 347898184e3Ssthen $suitemask, $producttype, $productinfo, $arch); 348b39c5158Smillert } 349b39c5158Smillert return wantarray ? ($cached_os, $cached_desc) : $cached_os; 350b39c5158Smillert} 351b39c5158Smillert 352898184e3Ssthensub GetOSDisplayName { 353898184e3Ssthen # Calling GetOSDisplayName() with arguments is for the test suite only! 354898184e3Ssthen my($name,$desc) = @_ ? @_ : GetOSName(); 355898184e3Ssthen $name =~ s/^Win//; 356898184e3Ssthen if ($desc =~ /^Windows Home Server\b/ || $desc =~ /^Windows XP Professional x64 Edition\b/) { 357898184e3Ssthen ($name, $desc) = ($desc, ""); 358898184e3Ssthen } 359898184e3Ssthen elsif ($desc =~ s/\s*(Windows (.*) Server( \d+)?)//) { 360898184e3Ssthen $name = "$1 $name"; 361898184e3Ssthen $desc =~ s/^\s+//; 362898184e3Ssthen } 363898184e3Ssthen else { 364898184e3Ssthen for ($name) { 365898184e3Ssthen s/^/Windows / unless /^Win32s$/; 366898184e3Ssthen s/\/.Net//; 367898184e3Ssthen s/NT(\d)/NT $1/; 368898184e3Ssthen if ($desc =~ s/\s*(HPC|Small Business|Web) Server//) { 369898184e3Ssthen my $name = $1; 370898184e3Ssthen $desc =~ s/^\s*//; 371898184e3Ssthen s/(200.)/$name Server $1/; 372898184e3Ssthen } 373*eac174f2Safresh1 s/^Windows (20(03|08|12|16|19))/Windows Server $1/; 374*eac174f2Safresh1 s/^Windows SAC/Windows Server/; 375898184e3Ssthen } 376898184e3Ssthen } 377898184e3Ssthen $name .= " $desc" if length $desc; 378898184e3Ssthen return $name; 379898184e3Ssthen} 380b39c5158Smillert 381898184e3Ssthensub _GetSystemMetrics { 382898184e3Ssthen my($index,$metrics) = @_; 383898184e3Ssthen return Win32::GetSystemMetrics($index) unless ref $metrics; 384898184e3Ssthen return $metrics->{$index} if ref $metrics eq "HASH" && defined $metrics->{$index}; 385898184e3Ssthen return 1 if ref $metrics eq "ARRAY" && grep $_ == $index, @$metrics; 386898184e3Ssthen return 0; 387898184e3Ssthen} 388898184e3Ssthen 389898184e3Ssthensub _GetOSName { 390898184e3Ssthen # The $metrics argument only exists for the benefit of t/GetOSName.t 391898184e3Ssthen my($csd, $major, $minor, $build, $id, $suitemask, $producttype, $productinfo, $arch, $metrics) = @_; 392898184e3Ssthen 393898184e3Ssthen my($os,@tags); 394898184e3Ssthen my $desc = ""; 395b39c5158Smillert if ($id == 0) { 396b39c5158Smillert $os = "Win32s"; 397b39c5158Smillert } 398b39c5158Smillert elsif ($id == 1) { 399898184e3Ssthen if ($minor == 0) { 400898184e3Ssthen $os = "95"; 401898184e3Ssthen } 402898184e3Ssthen elsif ($minor == 10) { 403898184e3Ssthen $os = "98"; 404898184e3Ssthen } 405898184e3Ssthen elsif ($minor == 90) { 406898184e3Ssthen $os = "Me"; 407898184e3Ssthen } 408b39c5158Smillert } 409b39c5158Smillert elsif ($id == 2) { 410b39c5158Smillert if ($major == 3) { 411b39c5158Smillert $os = "NT3.51"; 412b39c5158Smillert } 413b39c5158Smillert elsif ($major == 4) { 414b39c5158Smillert $os = "NT4"; 415b39c5158Smillert } 416b39c5158Smillert elsif ($major == 5) { 417898184e3Ssthen if ($minor == 0) { 418898184e3Ssthen $os = "2000"; 419898184e3Ssthen if ($producttype == VER_NT_WORKSTATION) { 420898184e3Ssthen $desc = "Professional"; 421898184e3Ssthen } 422898184e3Ssthen else { 423898184e3Ssthen if ($suitemask & VER_SUITE_DATACENTER) { 424898184e3Ssthen $desc = "Datacenter Server"; 425898184e3Ssthen } 426898184e3Ssthen elsif ($suitemask & VER_SUITE_ENTERPRISE) { 427898184e3Ssthen $desc = "Advanced Server"; 428898184e3Ssthen } 429898184e3Ssthen elsif ($suitemask & VER_SUITE_SMALLBUSINESS_RESTRICTED) { 430898184e3Ssthen $desc = "Small Business Server"; 431898184e3Ssthen } 432898184e3Ssthen else { 433898184e3Ssthen $desc = "Server"; 434898184e3Ssthen } 435898184e3Ssthen } 436898184e3Ssthen # XXX ignoring "Windows 2000 Advanced Server Limited Edition" for Itanium 437898184e3Ssthen # XXX and "Windows 2000 Datacenter Server Limited Edition" for Itanium 438898184e3Ssthen } 439898184e3Ssthen elsif ($minor == 1) { 440898184e3Ssthen $os = "XP/.Net"; 441898184e3Ssthen if (_GetSystemMetrics(SM_MEDIACENTER, $metrics)) { 442898184e3Ssthen $desc = "Media Center Edition"; 443898184e3Ssthen } 444898184e3Ssthen elsif (_GetSystemMetrics(SM_TABLETPC, $metrics)) { 445898184e3Ssthen # Tablet PC Edition is based on XP Pro 446898184e3Ssthen $desc = "Tablet PC Edition"; 447898184e3Ssthen } 448898184e3Ssthen elsif (_GetSystemMetrics(SM_STARTER, $metrics)) { 449898184e3Ssthen $desc = "Starter Edition"; 450898184e3Ssthen } 451898184e3Ssthen elsif ($suitemask & VER_SUITE_PERSONAL) { 452898184e3Ssthen $desc = "Home Edition"; 453898184e3Ssthen } 454898184e3Ssthen else { 455898184e3Ssthen $desc = "Professional"; 456898184e3Ssthen } 457898184e3Ssthen # XXX ignoring all Windows XP Embedded and Fundamentals versions 458898184e3Ssthen } 459898184e3Ssthen elsif ($minor == 2) { 460898184e3Ssthen $os = "2003"; 461898184e3Ssthen 462898184e3Ssthen if (_GetSystemMetrics(SM_SERVERR2, $metrics)) { 463898184e3Ssthen # XXX R2 was released for all x86 and x64 versions, 464898184e3Ssthen # XXX but only Enterprise Edition for Itanium. 465898184e3Ssthen $desc = "R2"; 466898184e3Ssthen } 467898184e3Ssthen 468898184e3Ssthen if ($suitemask == VER_SUITE_STORAGE_SERVER) { 469898184e3Ssthen $desc .= " Windows Storage Server"; 470898184e3Ssthen } 471898184e3Ssthen elsif ($suitemask == VER_SUITE_WH_SERVER) { 472898184e3Ssthen $desc .= " Windows Home Server"; 473898184e3Ssthen } 474898184e3Ssthen elsif ($producttype == VER_NT_WORKSTATION && $arch == PROCESSOR_ARCHITECTURE_AMD64) { 475898184e3Ssthen $desc .= " Windows XP Professional x64 Edition"; 476898184e3Ssthen } 477898184e3Ssthen 478898184e3Ssthen # Test for the server type. 479898184e3Ssthen if ($producttype != VER_NT_WORKSTATION) { 480898184e3Ssthen if ($arch == PROCESSOR_ARCHITECTURE_IA64) { 481898184e3Ssthen if ($suitemask & VER_SUITE_DATACENTER) { 482898184e3Ssthen $desc .= " Datacenter Edition for Itanium-based Systems"; 483898184e3Ssthen } 484898184e3Ssthen elsif ($suitemask & VER_SUITE_ENTERPRISE) { 485898184e3Ssthen $desc .= " Enterprise Edition for Itanium-based Systems"; 486898184e3Ssthen } 487898184e3Ssthen } 488898184e3Ssthen elsif ($arch == PROCESSOR_ARCHITECTURE_AMD64) { 489898184e3Ssthen if ($suitemask & VER_SUITE_DATACENTER) { 490898184e3Ssthen $desc .= " Datacenter x64 Edition"; 491898184e3Ssthen } 492898184e3Ssthen elsif ($suitemask & VER_SUITE_ENTERPRISE) { 493898184e3Ssthen $desc .= " Enterprise x64 Edition"; 494898184e3Ssthen } 495898184e3Ssthen else { 496898184e3Ssthen $desc .= " Standard x64 Edition"; 497898184e3Ssthen } 498898184e3Ssthen } 499898184e3Ssthen else { 500898184e3Ssthen if ($suitemask & VER_SUITE_COMPUTE_SERVER) { 501898184e3Ssthen $desc .= " Windows Compute Cluster Server"; 502898184e3Ssthen } 503898184e3Ssthen elsif ($suitemask & VER_SUITE_DATACENTER) { 504898184e3Ssthen $desc .= " Datacenter Edition"; 505898184e3Ssthen } 506898184e3Ssthen elsif ($suitemask & VER_SUITE_ENTERPRISE) { 507898184e3Ssthen $desc .= " Enterprise Edition"; 508898184e3Ssthen } 509898184e3Ssthen elsif ($suitemask & VER_SUITE_BLADE) { 510898184e3Ssthen $desc .= " Web Edition"; 511898184e3Ssthen } 512898184e3Ssthen elsif ($suitemask & VER_SUITE_SMALLBUSINESS_RESTRICTED) { 513898184e3Ssthen $desc .= " Small Business Server"; 514898184e3Ssthen } 515898184e3Ssthen else { 516898184e3Ssthen if ($desc !~ /Windows (Home|Storage) Server/) { 517898184e3Ssthen $desc .= " Standard Edition"; 518898184e3Ssthen } 519898184e3Ssthen } 520898184e3Ssthen } 521898184e3Ssthen } 522898184e3Ssthen } 523b39c5158Smillert } 524b39c5158Smillert elsif ($major == 6) { 525898184e3Ssthen if ($minor == 0) { 526898184e3Ssthen if ($producttype == VER_NT_WORKSTATION) { 527898184e3Ssthen $os = "Vista"; 528898184e3Ssthen } 529898184e3Ssthen else { 530898184e3Ssthen $os = "2008"; 531898184e3Ssthen } 532898184e3Ssthen } 533898184e3Ssthen elsif ($minor == 1) { 534898184e3Ssthen if ($producttype == VER_NT_WORKSTATION) { 535898184e3Ssthen $os = "7"; 536898184e3Ssthen } 537898184e3Ssthen else { 538898184e3Ssthen $os = "2008"; 539898184e3Ssthen $desc = "R2"; 540898184e3Ssthen } 541898184e3Ssthen } 54291f110e0Safresh1 elsif ($minor == 2) { 54391f110e0Safresh1 if ($producttype == VER_NT_WORKSTATION) { 54491f110e0Safresh1 $os = "8"; 54591f110e0Safresh1 } 54691f110e0Safresh1 else { 54791f110e0Safresh1 $os = "2012"; 54891f110e0Safresh1 } 54991f110e0Safresh1 } 550b8851fccSafresh1 elsif ($minor == 3) { 551b8851fccSafresh1 if ($producttype == VER_NT_WORKSTATION) { 552b8851fccSafresh1 $os = "8.1"; 553b8851fccSafresh1 } 554b8851fccSafresh1 else { 555b8851fccSafresh1 $os = "2012"; 556b8851fccSafresh1 $desc = "R2"; 557b8851fccSafresh1 } 558b8851fccSafresh1 } 559b8851fccSafresh1 } 560b8851fccSafresh1 elsif ($major == 10) { 561*eac174f2Safresh1 if ($producttype == VER_NT_WORKSTATION) { 562*eac174f2Safresh1 # Build numbers from https://en.wikipedia.org/wiki/Windows_10_version_history 563b8851fccSafresh1 $os = '10'; 564*eac174f2Safresh1 if (9841 <= $build && $build <= 10240) { 565*eac174f2Safresh1 $desc = " Version 1507"; 566*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 10240; 567*eac174f2Safresh1 $desc .= " (RTM)" if $build == 10240; 568*eac174f2Safresh1 } 569*eac174f2Safresh1 elsif (10525 <= $build && $build <= 10586) { 570*eac174f2Safresh1 $desc = " Version 1511 (November Update)"; 571*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 10586; 572*eac174f2Safresh1 } 573*eac174f2Safresh1 elsif (11082 <= $build && $build <= 14393) { 574*eac174f2Safresh1 $desc = " Version 1607 (Anniversary Update)"; 575*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 14393; 576*eac174f2Safresh1 } 577*eac174f2Safresh1 elsif (14901 <= $build && $build <= 15063) { 578*eac174f2Safresh1 $desc = " Version 1703 (Creators Update)"; 579*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 15063; 580*eac174f2Safresh1 } 581*eac174f2Safresh1 elsif (16170 <= $build && $build <= 16299) { 582*eac174f2Safresh1 $desc = " Version 1709 (Fall Creators Update)"; 583*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 16299; 584*eac174f2Safresh1 } 585*eac174f2Safresh1 elsif (16353 <= $build && $build <= 17134) { 586*eac174f2Safresh1 $desc = " Version 1803 (April 2018 Update)"; 587*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 17134; 588*eac174f2Safresh1 } 589*eac174f2Safresh1 elsif (17604 <= $build && $build <= 17763) { 590*eac174f2Safresh1 $desc = " Version 1809 (October 2018 Update)"; 591*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 17763; 592*eac174f2Safresh1 } 593*eac174f2Safresh1 elsif (18204 <= $build && $build <= 18362) { 594*eac174f2Safresh1 $desc = " Version 1903 (May 2019 Update)"; 595*eac174f2Safresh1 $desc .= " (Preview Build $build)" if $build < 18362; 596*eac174f2Safresh1 } 597*eac174f2Safresh1 else { 598*eac174f2Safresh1 $desc = " Build $build"; 599*eac174f2Safresh1 } 600*eac174f2Safresh1 } 601*eac174f2Safresh1 else { 602*eac174f2Safresh1 if ($build == 14393) { 603*eac174f2Safresh1 $os = "2016"; 604*eac174f2Safresh1 $desc = "Version 1607"; 605*eac174f2Safresh1 } 606*eac174f2Safresh1 elsif ($build == 17763) { 607*eac174f2Safresh1 $os = "2019"; 608*eac174f2Safresh1 $desc = "Version 1809"; 609*eac174f2Safresh1 } 610*eac174f2Safresh1 else { 611*eac174f2Safresh1 $os = "Server"; 612*eac174f2Safresh1 if ($build == 16299) { 613*eac174f2Safresh1 $desc = "Version 1709"; 614*eac174f2Safresh1 } 615*eac174f2Safresh1 elsif ($build == 17134) { 616*eac174f2Safresh1 $desc = "Version 1803"; 617*eac174f2Safresh1 } 618*eac174f2Safresh1 elsif ($build == 18362) { 619*eac174f2Safresh1 $desc = "Version 1903"; 620*eac174f2Safresh1 } 621*eac174f2Safresh1 else { 622*eac174f2Safresh1 $desc = "Build $build"; 623*eac174f2Safresh1 } 624*eac174f2Safresh1 } 625*eac174f2Safresh1 } 626b8851fccSafresh1 } 627898184e3Ssthen 628b8851fccSafresh1 if ($major >= 6) { 629*eac174f2Safresh1 if ($major == 6) { 630898184e3Ssthen if ($productinfo == PRODUCT_ULTIMATE) { 631898184e3Ssthen $desc .= " Ultimate"; 632898184e3Ssthen } 633898184e3Ssthen elsif ($productinfo == PRODUCT_HOME_PREMIUM) { 634898184e3Ssthen $desc .= " Home Premium"; 635898184e3Ssthen } 636898184e3Ssthen elsif ($productinfo == PRODUCT_HOME_BASIC) { 637898184e3Ssthen $desc .= " Home Basic"; 638898184e3Ssthen } 639898184e3Ssthen elsif ($productinfo == PRODUCT_ENTERPRISE) { 640898184e3Ssthen $desc .= " Enterprise"; 641898184e3Ssthen } 642898184e3Ssthen elsif ($productinfo == PRODUCT_BUSINESS) { 643898184e3Ssthen # "Windows 7 Business" had a name change to "Windows 7 Professional" 644898184e3Ssthen $desc .= $minor == 0 ? " Business" : " Professional"; 645898184e3Ssthen } 646898184e3Ssthen elsif ($productinfo == PRODUCT_STARTER) { 647898184e3Ssthen $desc .= " Starter"; 648898184e3Ssthen } 649898184e3Ssthen elsif ($productinfo == PRODUCT_CLUSTER_SERVER) { 650898184e3Ssthen $desc .= " HPC Server"; 651898184e3Ssthen } 652898184e3Ssthen elsif ($productinfo == PRODUCT_DATACENTER_SERVER) { 653898184e3Ssthen $desc .= " Datacenter"; 654898184e3Ssthen } 655898184e3Ssthen elsif ($productinfo == PRODUCT_DATACENTER_SERVER_CORE) { 656898184e3Ssthen $desc .= " Datacenter Edition (core installation)"; 657898184e3Ssthen } 658898184e3Ssthen elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER) { 659898184e3Ssthen $desc .= " Enterprise"; 660898184e3Ssthen } 661898184e3Ssthen elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_CORE) { 662898184e3Ssthen $desc .= " Enterprise Edition (core installation)"; 663898184e3Ssthen } 664898184e3Ssthen elsif ($productinfo == PRODUCT_ENTERPRISE_SERVER_IA64) { 665898184e3Ssthen $desc .= " Enterprise Edition for Itanium-based Systems"; 666898184e3Ssthen } 667898184e3Ssthen elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER) { 668898184e3Ssthen $desc .= " Small Business Server"; 669898184e3Ssthen } 670898184e3Ssthen elsif ($productinfo == PRODUCT_SMALLBUSINESS_SERVER_PREMIUM) { 671898184e3Ssthen $desc .= " Small Business Server Premium Edition"; 672898184e3Ssthen } 673898184e3Ssthen elsif ($productinfo == PRODUCT_STANDARD_SERVER) { 674898184e3Ssthen $desc .= " Standard"; 675898184e3Ssthen } 676898184e3Ssthen elsif ($productinfo == PRODUCT_STANDARD_SERVER_CORE) { 677898184e3Ssthen $desc .= " Standard Edition (core installation)"; 678898184e3Ssthen } 679898184e3Ssthen elsif ($productinfo == PRODUCT_WEB_SERVER) { 680898184e3Ssthen $desc .= " Web Server"; 681898184e3Ssthen } 682898184e3Ssthen elsif ($productinfo == PRODUCT_PROFESSIONAL) { 683898184e3Ssthen $desc .= " Professional"; 684898184e3Ssthen } 685*eac174f2Safresh1 } 686898184e3Ssthen 687898184e3Ssthen if ($arch == PROCESSOR_ARCHITECTURE_INTEL) { 688898184e3Ssthen $desc .= " (32-bit)"; 689898184e3Ssthen } 690898184e3Ssthen elsif ($arch == PROCESSOR_ARCHITECTURE_AMD64) { 691898184e3Ssthen $desc .= " (64-bit)"; 692898184e3Ssthen } 693b39c5158Smillert } 694b39c5158Smillert } 695b39c5158Smillert 696b39c5158Smillert unless (defined $os) { 697b39c5158Smillert warn "Unknown Windows version [$id:$major:$minor]"; 698b39c5158Smillert return; 699b39c5158Smillert } 700b39c5158Smillert 701898184e3Ssthen for ($desc) { 702898184e3Ssthen s/\s\s+/ /g; 703898184e3Ssthen s/^\s//; 704898184e3Ssthen s/\s$//; 705b39c5158Smillert } 706b39c5158Smillert 707898184e3Ssthen # XXX What about "Small Business Server"? NT, 200, 2003, 2008 editions... 708898184e3Ssthen 709898184e3Ssthen if ($major >= 5) { 710898184e3Ssthen # XXX XP, Vista, 7 all have starter editions 711898184e3Ssthen #push(@tags, "Starter Edition") if _GetSystemMetrics(SM_STARTER, $metrics); 712898184e3Ssthen } 713898184e3Ssthen 714898184e3Ssthen if (@tags) { 715898184e3Ssthen unshift(@tags, $desc) if length $desc; 716898184e3Ssthen $desc = join(" ", @tags); 717898184e3Ssthen } 718898184e3Ssthen 719898184e3Ssthen if (length $csd) { 720898184e3Ssthen $desc .= " " if length $desc; 721898184e3Ssthen $desc .= $csd; 722898184e3Ssthen } 723b39c5158Smillert return ("Win$os", $desc); 724b39c5158Smillert} 725b39c5158Smillert 726*eac174f2Safresh1sub IsSymlinkCreationAllowed { 727*eac174f2Safresh1 my(undef, $major, $minor, $build) = GetOSVersion(); 728*eac174f2Safresh1 729*eac174f2Safresh1 # Vista was the first Windows version with symlink support 730*eac174f2Safresh1 return !!0 if $major < 6; 731*eac174f2Safresh1 732*eac174f2Safresh1 # Since Windows 10 1703, enabling the developer mode allows to create 733*eac174f2Safresh1 # symlinks regardless of process privileges 734*eac174f2Safresh1 if ($major > 10 || ($major == 10 && ($minor > 0 || $build > 15063))) { 735*eac174f2Safresh1 return !!1 if IsDeveloperModeEnabled(); 736*eac174f2Safresh1 } 737*eac174f2Safresh1 738*eac174f2Safresh1 my $privs = GetProcessPrivileges(); 739*eac174f2Safresh1 740*eac174f2Safresh1 return !!0 unless $privs; 741*eac174f2Safresh1 742*eac174f2Safresh1 # It doesn't matter if the permission is enabled or not, it just has to 743*eac174f2Safresh1 # exist. CreateSymbolicLink() will automatically enable it when needed. 744*eac174f2Safresh1 return exists $privs->{SeCreateSymbolicLinkPrivilege}; 745*eac174f2Safresh1} 746*eac174f2Safresh1 747b39c5158Smillert# "no warnings 'redefine';" doesn't work for 5.8.7 and earlier 748b39c5158Smillertlocal $^W = 0; 749b39c5158Smillertbootstrap Win32; 750b39c5158Smillert 751b39c5158Smillert1; 752b39c5158Smillert 753b39c5158Smillert__END__ 754b39c5158Smillert 755b39c5158Smillert=head1 NAME 756b39c5158Smillert 757b39c5158SmillertWin32 - Interfaces to some Win32 API Functions 758b39c5158Smillert 759b39c5158Smillert=head1 DESCRIPTION 760b39c5158Smillert 761b39c5158SmillertThe Win32 module contains functions to access Win32 APIs. 762b39c5158Smillert 763b39c5158Smillert=head2 Alphabetical Listing of Win32 Functions 764b39c5158Smillert 765b39c5158SmillertIt is recommended to C<use Win32;> before any of these functions; 766b39c5158Smillerthowever, for backwards compatibility, those marked as [CORE] will 767b39c5158Smillertautomatically do this for you. 768b39c5158Smillert 769b39c5158SmillertIn the function descriptions below the term I<Unicode string> is used 770b39c5158Smillertto indicate that the string may contain characters outside the system 771b39c5158Smillertcodepage. The caveat I<If supported by the core Perl version> 772b39c5158Smillertgenerally means Perl 5.8.9 and later, though some Unicode pathname 773b39c5158Smillertfunctionality may work on earlier versions. 774b39c5158Smillert 775b39c5158Smillert=over 776b39c5158Smillert 777b39c5158Smillert=item Win32::AbortSystemShutdown(MACHINE) 778b39c5158Smillert 779b39c5158SmillertAborts a system shutdown (started by the 780b39c5158SmillertInitiateSystemShutdown function) on the specified MACHINE. 781b39c5158Smillert 782b39c5158Smillert=item Win32::BuildNumber() 783b39c5158Smillert 784b39c5158Smillert[CORE] Returns the ActivePerl build number. This function is 785b39c5158Smillertonly available in the ActivePerl binary distribution. 786b39c5158Smillert 787b39c5158Smillert=item Win32::CopyFile(FROM, TO, OVERWRITE) 788b39c5158Smillert 789b39c5158Smillert[CORE] The Win32::CopyFile() function copies an existing file to a new 790b39c5158Smillertfile. All file information like creation time and file attributes will 791b39c5158Smillertbe copied to the new file. However it will B<not> copy the security 792b39c5158Smillertinformation. If the destination file already exists it will only be 793b39c5158Smillertoverwritten when the OVERWRITE parameter is true. But even this will 794b39c5158Smillertnot overwrite a read-only file; you have to unlink() it first 795b39c5158Smillertyourself. 796b39c5158Smillert 797b39c5158Smillert=item Win32::CreateDirectory(DIRECTORY) 798b39c5158Smillert 799b39c5158SmillertCreates the DIRECTORY and returns a true value on success. Check $^E 800b39c5158Smillerton failure for extended error information. 801b39c5158Smillert 802b39c5158SmillertDIRECTORY may contain Unicode characters outside the system codepage. 803b39c5158SmillertOnce the directory has been created you can use 804b39c5158SmillertWin32::GetANSIPathName() to get a name that can be passed to system 805b39c5158Smillertcalls and external programs. 806b39c5158Smillert 807b39c5158Smillert=item Win32::CreateFile(FILE) 808b39c5158Smillert 809b39c5158SmillertCreates the FILE and returns a true value on success. Check $^E on 810b39c5158Smillertfailure for extended error information. 811b39c5158Smillert 812b39c5158SmillertFILE may contain Unicode characters outside the system codepage. Once 813b39c5158Smillertthe file has been created you can use Win32::GetANSIPathName() to get 814b39c5158Smillerta name that can be passed to system calls and external programs. 815b39c5158Smillert 816b39c5158Smillert=item Win32::DomainName() 817b39c5158Smillert 818b39c5158Smillert[CORE] Returns the name of the Microsoft Network domain or workgroup 819b39c5158Smillertthat the owner of the current perl process is logged into. The 820b39c5158Smillert"Workstation" service must be running to determine this 821b39c5158Smillertinformation. This function does B<not> work on Windows 9x. 822b39c5158Smillert 823b39c5158Smillert=item Win32::ExpandEnvironmentStrings(STRING) 824b39c5158Smillert 825b39c5158SmillertTakes STRING and replaces all referenced environment variable 826b39c5158Smillertnames with their defined values. References to environment variables 827b39c5158Smillerttake the form C<%VariableName%>. Case is ignored when looking up the 828b39c5158SmillertVariableName in the environment. If the variable is not found then the 829b39c5158Smillertoriginal C<%VariableName%> text is retained. Has the same effect 830b39c5158Smillertas the following: 831b39c5158Smillert 832b39c5158Smillert $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg 833b39c5158Smillert 834b39c5158SmillertHowever, this function may return a Unicode string if the environment 835b39c5158Smillertvariable being expanded hasn't been assigned to via %ENV. Access 836b39c5158Smillertto %ENV is currently always using byte semantics. 837b39c5158Smillert 838b39c5158Smillert=item Win32::FormatMessage(ERRORCODE) 839b39c5158Smillert 840b39c5158Smillert[CORE] Converts the supplied Win32 error number (e.g. returned by 841b39c5158SmillertWin32::GetLastError()) to a descriptive string. Analogous to the 842b39c5158Smillertperror() standard-C library function. Note that C<$^E> used 843b39c5158Smillertin a string context has much the same effect. 844b39c5158Smillert 845b39c5158Smillert C:\> perl -e "$^E = 26; print $^E;" 846b39c5158Smillert The specified disk or diskette cannot be accessed 847b39c5158Smillert 848b39c5158Smillert=item Win32::FsType() 849b39c5158Smillert 850b39c5158Smillert[CORE] Returns the name of the filesystem of the currently active 851b39c5158Smillertdrive (like 'FAT' or 'NTFS'). In list context it returns three values: 852b39c5158Smillert(FSTYPE, FLAGS, MAXCOMPLEN). FSTYPE is the filesystem type as 853b39c5158Smillertbefore. FLAGS is a combination of values of the following table: 854b39c5158Smillert 855b39c5158Smillert 0x00000001 supports case-sensitive filenames 856b39c5158Smillert 0x00000002 preserves the case of filenames 857b39c5158Smillert 0x00000004 supports Unicode in filenames 858b39c5158Smillert 0x00000008 preserves and enforces ACLs 859b39c5158Smillert 0x00000010 supports file-based compression 860b39c5158Smillert 0x00000020 supports disk quotas 861b39c5158Smillert 0x00000040 supports sparse files 862b39c5158Smillert 0x00000080 supports reparse points 863b39c5158Smillert 0x00000100 supports remote storage 864b39c5158Smillert 0x00008000 is a compressed volume (e.g. DoubleSpace) 865b39c5158Smillert 0x00010000 supports object identifiers 866b39c5158Smillert 0x00020000 supports the Encrypted File System (EFS) 867b39c5158Smillert 868b39c5158SmillertMAXCOMPLEN is the maximum length of a filename component (the part 869b39c5158Smillertbetween two backslashes) on this file system. 870b39c5158Smillert 871b39c5158Smillert=item Win32::FreeLibrary(HANDLE) 872b39c5158Smillert 873b39c5158SmillertUnloads a previously loaded dynamic-link library. The HANDLE is 874b39c5158Smillertno longer valid after this call. See L<LoadLibrary|Win32::LoadLibrary(LIBNAME)> 875b39c5158Smillertfor information on dynamically loading a library. 876b39c5158Smillert 87791f110e0Safresh1=item Win32::GetACP() 87891f110e0Safresh1 87991f110e0Safresh1Returns the current Windows ANSI code page identifier for the operating 88091f110e0Safresh1system. See also GetOEMCP(), GetConsoleCP() and GetConsoleOutputCP(). 88191f110e0Safresh1 882b39c5158Smillert=item Win32::GetANSIPathName(FILENAME) 883b39c5158Smillert 884b39c5158SmillertReturns an ANSI version of FILENAME. This may be the short name 885b39c5158Smillertif the long name cannot be represented in the system codepage. 886b39c5158Smillert 887b39c5158SmillertWhile not currently implemented, it is possible that in the future 888b39c5158Smillertthis function will convert only parts of the path to FILENAME to a 889b39c5158Smillertshort form. 890b39c5158Smillert 891b39c5158SmillertIf FILENAME doesn't exist on the filesystem, or if the filesystem 892b39c5158Smillertdoesn't support short ANSI filenames, then this function will 893b39c5158Smillerttranslate the Unicode name into the system codepage using replacement 894b39c5158Smillertcharacters. 895b39c5158Smillert 896b39c5158Smillert=item Win32::GetArchName() 897b39c5158Smillert 898b39c5158SmillertUse of this function is deprecated. It is equivalent with 899b39c5158Smillert$ENV{PROCESSOR_ARCHITECTURE}. This might not work on Win9X. 900b39c5158Smillert 901b39c5158Smillert=item Win32::GetChipName() 902b39c5158Smillert 903*eac174f2Safresh1Returns the processor type: 386, 486 or 586 for x86 processors, 8664 for the x64 904*eac174f2Safresh1processor and 2200 for the Itanium. For arm/arm64 processor, the value is marked 905*eac174f2Safresh1as "Reserved" (not specified, but usually 0) in Microsoft documentation, so it's 906*eac174f2Safresh1better to use GetChipArch(). Since it returns the native processor type it will 907*eac174f2Safresh1return a 64-bit processor type even when called from a 32-bit Perl running on 908*eac174f2Safresh164-bit Windows. 909*eac174f2Safresh1 910*eac174f2Safresh1=item Win32::GetChipArch() 911*eac174f2Safresh1 912*eac174f2Safresh1Returns the processor architecture: 0 for x86 processors, 5 for arm, 6 for 913*eac174f2Safresh1Itanium, 9 for x64 and 12 for arm64, and 0xFFFF for unknown architecture. 914b39c5158Smillert 91591f110e0Safresh1=item Win32::GetConsoleCP() 91691f110e0Safresh1 91791f110e0Safresh1Returns the input code page used by the console associated with the 91891f110e0Safresh1calling process. To set the console's input code page, see 91991f110e0Safresh1SetConsoleCP(). See also GetConsoleOutputCP(), GetACP() and 92091f110e0Safresh1GetOEMCP(). 92191f110e0Safresh1 92291f110e0Safresh1=item Win32::GetConsoleOutputCP() 92391f110e0Safresh1 92491f110e0Safresh1Returns the output code page used by the console associated with the 92591f110e0Safresh1calling process. To set the console's output code page, see 92691f110e0Safresh1SetConsoleOutputCP(). See also GetConsoleCP(), GetACP(), and 92791f110e0Safresh1GetOEMCP(). 92891f110e0Safresh1 929b39c5158Smillert=item Win32::GetCwd() 930b39c5158Smillert 931b39c5158Smillert[CORE] Returns the current active drive and directory. This function 932b39c5158Smillertdoes not return a UNC path, since the functionality required for such 933b39c5158Smillerta feature is not available under Windows 95. 934b39c5158Smillert 935b39c5158SmillertIf supported by the core Perl version, this function will return an 936b39c5158SmillertANSI path name for the current directory if the long pathname cannot 937b39c5158Smillertbe represented in the system codepage. 938b39c5158Smillert 939b39c5158Smillert=item Win32::GetCurrentProcessId() 940b39c5158Smillert 941b39c5158SmillertReturns the process identifier of the current process. Until the 942b39c5158Smillertprocess terminates, the process identifier uniquely identifies the 943b39c5158Smillertprocess throughout the system. 944b39c5158Smillert 945b39c5158SmillertThe current process identifier is normally also available via the 946b39c5158Smillertpredefined $$ variable. Under fork() emulation however $$ may contain 947b39c5158Smillerta pseudo-process identifier that is only meaningful to the Perl 948b39c5158Smillertkill(), wait() and waitpid() functions. The 949b39c5158SmillertWin32::GetCurrentProcessId() function will always return the regular 950b39c5158SmillertWindows process id, even when called from inside a pseudo-process. 951b39c5158Smillert 952b39c5158Smillert=item Win32::GetCurrentThreadId() 953b39c5158Smillert 954b39c5158SmillertReturns the thread identifier of the calling thread. Until the thread 955b39c5158Smillertterminates, the thread identifier uniquely identifies the thread 956b39c5158Smillertthroughout the system. 957b39c5158Smillert 958b39c5158Smillert=item Win32::GetFileVersion(FILENAME) 959b39c5158Smillert 960b39c5158SmillertReturns the file version number from the VERSIONINFO resource of 961b39c5158Smillertthe executable file or DLL. This is a tuple of four 16 bit numbers. 962b39c5158SmillertIn list context these four numbers will be returned. In scalar context 963b39c5158Smillertthey are concatenated into a string, separated by dots. 964b39c5158Smillert 965b39c5158Smillert=item Win32::GetFolderPath(FOLDER [, CREATE]) 966b39c5158Smillert 967b39c5158SmillertReturns the full pathname of one of the Windows special folders. 968b39c5158SmillertThe folder will be created if it doesn't exist and the optional CREATE 969b39c5158Smillertargument is true. The following FOLDER constants are defined by the 970b39c5158SmillertWin32 module, but only exported on demand: 971b39c5158Smillert 972b39c5158Smillert CSIDL_ADMINTOOLS 973b39c5158Smillert CSIDL_APPDATA 974b39c5158Smillert CSIDL_CDBURN_AREA 975b39c5158Smillert CSIDL_COMMON_ADMINTOOLS 976b39c5158Smillert CSIDL_COMMON_APPDATA 977b39c5158Smillert CSIDL_COMMON_DESKTOPDIRECTORY 978b39c5158Smillert CSIDL_COMMON_DOCUMENTS 979b39c5158Smillert CSIDL_COMMON_FAVORITES 980b39c5158Smillert CSIDL_COMMON_MUSIC 981b39c5158Smillert CSIDL_COMMON_PICTURES 982b39c5158Smillert CSIDL_COMMON_PROGRAMS 983b39c5158Smillert CSIDL_COMMON_STARTMENU 984b39c5158Smillert CSIDL_COMMON_STARTUP 985b39c5158Smillert CSIDL_COMMON_TEMPLATES 986b39c5158Smillert CSIDL_COMMON_VIDEO 987b39c5158Smillert CSIDL_COOKIES 988b39c5158Smillert CSIDL_DESKTOP 989b39c5158Smillert CSIDL_DESKTOPDIRECTORY 990b39c5158Smillert CSIDL_FAVORITES 991b39c5158Smillert CSIDL_FONTS 992b39c5158Smillert CSIDL_HISTORY 993b39c5158Smillert CSIDL_INTERNET_CACHE 994b39c5158Smillert CSIDL_LOCAL_APPDATA 995b39c5158Smillert CSIDL_MYMUSIC 996b39c5158Smillert CSIDL_MYPICTURES 997b39c5158Smillert CSIDL_MYVIDEO 998b39c5158Smillert CSIDL_NETHOOD 999b39c5158Smillert CSIDL_PERSONAL 1000b39c5158Smillert CSIDL_PRINTHOOD 1001b39c5158Smillert CSIDL_PROFILE 1002b39c5158Smillert CSIDL_PROGRAMS 1003b39c5158Smillert CSIDL_PROGRAM_FILES 1004b39c5158Smillert CSIDL_PROGRAM_FILES_COMMON 1005b39c5158Smillert CSIDL_RECENT 1006b39c5158Smillert CSIDL_RESOURCES 1007b39c5158Smillert CSIDL_RESOURCES_LOCALIZED 1008b39c5158Smillert CSIDL_SENDTO 1009b39c5158Smillert CSIDL_STARTMENU 1010b39c5158Smillert CSIDL_STARTUP 1011b39c5158Smillert CSIDL_SYSTEM 1012b39c5158Smillert CSIDL_TEMPLATES 1013b39c5158Smillert CSIDL_WINDOWS 1014b39c5158Smillert 1015b39c5158SmillertNote that not all folders are defined on all versions of Windows. 1016b39c5158Smillert 1017b39c5158SmillertPlease refer to the MSDN documentation of the CSIDL constants, 1018b39c5158Smillertcurrently available at: 1019b39c5158Smillert 1020b39c5158Smillerthttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp 1021b39c5158Smillert 1022b39c5158SmillertThis function will return an ANSI folder path if the long name cannot 1023b39c5158Smillertbe represented in the system codepage. Use Win32::GetLongPathName() 1024b39c5158Smillerton the result of Win32::GetFolderPath() if you want the Unicode 1025b39c5158Smillertversion of the folder name. 1026b39c5158Smillert 1027b39c5158Smillert=item Win32::GetFullPathName(FILENAME) 1028b39c5158Smillert 1029b39c5158Smillert[CORE] GetFullPathName combines the FILENAME with the current drive 1030b39c5158Smillertand directory name and returns a fully qualified (aka, absolute) 1031b39c5158Smillertpath name. In list context it returns two elements: (PATH, FILE) where 1032b39c5158SmillertPATH is the complete pathname component (including trailing backslash) 1033b39c5158Smillertand FILE is just the filename part. Note that no attempt is made to 1034b39c5158Smillertconvert 8.3 components in the supplied FILENAME to longnames or 1035b39c5158Smillertvice-versa. Compare with Win32::GetShortPathName() and 1036b39c5158SmillertWin32::GetLongPathName(). 1037b39c5158Smillert 1038b39c5158SmillertIf supported by the core Perl version, this function will return an 1039b39c5158SmillertANSI path name if the full pathname cannot be represented in the 1040b39c5158Smillertsystem codepage. 1041b39c5158Smillert 1042b39c5158Smillert=item Win32::GetLastError() 1043b39c5158Smillert 1044b39c5158Smillert[CORE] Returns the last error value generated by a call to a Win32 API 1045b39c5158Smillertfunction. Note that C<$^E> used in a numeric context amounts to the 1046b39c5158Smillertsame value. 1047b39c5158Smillert 1048b39c5158Smillert=item Win32::GetLongPathName(PATHNAME) 1049b39c5158Smillert 1050b39c5158Smillert[CORE] Returns a representation of PATHNAME composed of longname 1051b39c5158Smillertcomponents (if any). The result may not necessarily be longer 1052b39c5158Smillertthan PATHNAME. No attempt is made to convert PATHNAME to the 1053b39c5158Smillertabsolute path. Compare with Win32::GetShortPathName() and 1054b39c5158SmillertWin32::GetFullPathName(). 1055b39c5158Smillert 1056b39c5158SmillertThis function may return the pathname in Unicode if it cannot be 1057b39c5158Smillertrepresented in the system codepage. Use Win32::GetANSIPathName() 1058b39c5158Smillertbefore passing the path to a system call or another program. 1059b39c5158Smillert 1060b39c5158Smillert=item Win32::GetNextAvailDrive() 1061b39c5158Smillert 1062b39c5158Smillert[CORE] Returns a string in the form of "<d>:" where <d> is the first 1063b39c5158Smillertavailable drive letter. 1064b39c5158Smillert 106591f110e0Safresh1=item Win32::GetOEMCP() 106691f110e0Safresh1 106791f110e0Safresh1Returns the current original equipment manufacturer (OEM) code page 106891f110e0Safresh1identifier for the operating system. See also GetACP(), GetConsoleCP() 106991f110e0Safresh1and GetConsoleOutputCP(). 107091f110e0Safresh1 1071898184e3Ssthen=item Win32::GetOSDisplayName() 1072898184e3Ssthen 1073898184e3SsthenReturns the "marketing" name of the Windows operating system version 1074898184e3Ssthenbeing used. It returns names like these (random samples): 1075898184e3Ssthen 1076898184e3Ssthen Windows 2000 Datacenter Server 1077898184e3Ssthen Windows XP Professional 1078898184e3Ssthen Windows XP Tablet PC Edition 1079898184e3Ssthen Windows Home Server 1080898184e3Ssthen Windows Server 2003 Enterprise Edition for Itanium-based Systems 1081898184e3Ssthen Windows Vista Ultimate (32-bit) 1082898184e3Ssthen Windows Small Business Server 2008 R2 (64-bit) 1083898184e3Ssthen 1084898184e3SsthenThe display name describes the native Windows version, so even on a 1085898184e3Ssthen32-bit Perl this function may return a "Windows ... (64-bit)" name 1086898184e3Ssthenwhen running on a 64-bit Windows. 1087898184e3Ssthen 1088898184e3SsthenThis function should only be used to display the actual OS name to the 1089898184e3Ssthenuser; it should not be used to determine the class of operating systems 1090898184e3Ssthenthis system belongs to. The Win32::GetOSName(), Win32::GetOSVersion, 1091898184e3SsthenWin32::GetProductInfo() and Win32::GetSystemMetrics() functions provide 1092898184e3Ssthenthe base information to check for certain capabilities, or for families 1093898184e3Ssthenof OS releases. 1094898184e3Ssthen 1095898184e3Ssthen=item Win32::GetOSName() 1096898184e3Ssthen 1097898184e3SsthenIn scalar context returns the name of the Win32 operating system 1098898184e3Ssthenbeing used. In list context returns a two element list of the OS name 1099898184e3Ssthenand whatever edition information is known about the particular build 1100898184e3Ssthen(for Win9X boxes) and whatever service packs have been installed. 1101898184e3SsthenThe latter is roughly equivalent to the first item returned by 1102898184e3SsthenGetOSVersion() in list context. 1103898184e3Ssthen 1104898184e3SsthenThe description will also include tags for other special editions, 1105898184e3Ssthenlike "R2", "Media Center", "Tablet PC", or "Starter Edition". 1106898184e3Ssthen 1107*eac174f2Safresh1In the Windows 10 / Server Semi-Annual Channel era, the description may 1108*eac174f2Safresh1contain the relevant ReleaseId value, but this is only inferred from 1109*eac174f2Safresh1the build number, not determined absolutely. 1110*eac174f2Safresh1 1111898184e3SsthenCurrently the possible values for the OS name are 1112898184e3Ssthen 1113898184e3Ssthen WinWin32s 1114898184e3Ssthen Win95 1115898184e3Ssthen Win98 1116898184e3Ssthen WinMe 1117898184e3Ssthen WinNT3.51 1118898184e3Ssthen WinNT4 1119898184e3Ssthen Win2000 1120898184e3Ssthen WinXP/.Net 1121898184e3Ssthen Win2003 1122898184e3Ssthen WinHomeSvr 1123898184e3Ssthen WinVista 1124898184e3Ssthen Win2008 1125898184e3Ssthen Win7 1126*eac174f2Safresh1 Win8 1127*eac174f2Safresh1 Win8.1 1128*eac174f2Safresh1 Win10 1129*eac174f2Safresh1 Win2016 1130*eac174f2Safresh1 Win2019 1131*eac174f2Safresh1 WinSAC 1132898184e3Ssthen 1133898184e3SsthenThis routine is just a simple interface into GetOSVersion(). More 1134898184e3Ssthenspecific or demanding situations should use that instead. Another 1135898184e3Ssthenoption would be to use POSIX::uname(), however the latter appears to 1136898184e3Ssthenreport only the OS family name and not the specific OS. In scalar 1137898184e3Ssthencontext it returns just the ID. 1138898184e3Ssthen 1139898184e3SsthenThe name "WinXP/.Net" is used for historical reasons only, to maintain 1140898184e3Ssthenbackwards compatibility of the Win32 module. Windows .NET Server has 1141898184e3Ssthenbeen renamed as Windows 2003 Server before final release and uses a 1142898184e3Ssthendifferent major/minor version number than Windows XP. 1143898184e3Ssthen 1144898184e3SsthenSimilarly the name "WinWin32s" should have been "Win32s" but has been 1145898184e3Ssthenkept as-is for backwards compatibility reasons too. 1146898184e3Ssthen 1147b39c5158Smillert=item Win32::GetOSVersion() 1148b39c5158Smillert 1149b39c5158Smillert[CORE] Returns the list (STRING, MAJOR, MINOR, BUILD, ID), where the 1150b39c5158Smillertelements are, respectively: An arbitrary descriptive string, the major 1151b39c5158Smillertversion number of the operating system, the minor version number, the 1152b39c5158Smillertbuild number, and a digit indicating the actual operating system. 1153b39c5158SmillertFor the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for 1154b39c5158SmillertWindows NT/2000/XP/2003/Vista/2008/7. In scalar context it returns just 1155b39c5158Smillertthe ID. 1156b39c5158Smillert 1157*eac174f2Safresh1Currently known values for ID MAJOR MINOR and BUILD are as follows: 1158b39c5158Smillert 1159*eac174f2Safresh1 OS ID MAJOR MINOR BUILD 1160*eac174f2Safresh1 Win32s 0 - - - 1161*eac174f2Safresh1 Windows 95 1 4 0 - 1162*eac174f2Safresh1 Windows 98 1 4 10 - 1163*eac174f2Safresh1 Windows Me 1 4 90 - 1164898184e3Ssthen 1165*eac174f2Safresh1 Windows NT 3.51 2 3 51 - 1166*eac174f2Safresh1 Windows NT 4 2 4 0 - 1167898184e3Ssthen 1168*eac174f2Safresh1 Windows 2000 2 5 0 - 1169*eac174f2Safresh1 Windows XP 2 5 1 - 1170*eac174f2Safresh1 Windows Server 2003 2 5 2 - 1171*eac174f2Safresh1 Windows Server 2003 R2 2 5 2 - 1172*eac174f2Safresh1 Windows Home Server 2 5 2 - 1173898184e3Ssthen 1174*eac174f2Safresh1 Windows Vista 2 6 0 - 1175*eac174f2Safresh1 Windows Server 2008 2 6 0 - 1176*eac174f2Safresh1 Windows 7 2 6 1 - 1177*eac174f2Safresh1 Windows Server 2008 R2 2 6 1 - 1178*eac174f2Safresh1 Windows 8 2 6 2 - 1179*eac174f2Safresh1 Windows Server 2012 2 6 2 - 1180*eac174f2Safresh1 Windows 8.1 2 6 2 - 1181*eac174f2Safresh1 Windows Server 2012 R2 2 6 2 - 1182*eac174f2Safresh1 1183*eac174f2Safresh1 Windows 10 2 10 0 - 1184*eac174f2Safresh1 Windows Server 2016 2 10 0 14393 1185*eac174f2Safresh1 Windows Server 2019 2 10 0 17677 1186b39c5158Smillert 1187b39c5158SmillertOn Windows NT 4 SP6 and later this function returns the following 1188b39c5158Smillertadditional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE. 1189b39c5158Smillert 1190898184e3SsthenThe version numbers for Windows 2003 and Windows Home Server are 11916fb12b70Safresh1identical; the SUITEMASK field must be used to differentiate between 1192898184e3Ssthenthem. 1193898184e3Ssthen 1194b39c5158SmillertThe version numbers for Windows Vista and Windows Server 2008 are 1195898184e3Ssthenidentical; the PRODUCTTYPE field must be used to differentiate between 1196898184e3Ssthenthem. 1197898184e3Ssthen 1198898184e3SsthenThe version numbers for Windows 7 and Windows Server 2008 R2 are 1199898184e3Ssthenidentical; the PRODUCTTYPE field must be used to differentiate between 1200898184e3Ssthenthem. 1201b39c5158Smillert 120291f110e0Safresh1The version numbers for Windows 8 and Windows Server 2012 are 120391f110e0Safresh1identical; the PRODUCTTYPE field must be used to differentiate between 120491f110e0Safresh1them. 120591f110e0Safresh1 1206*eac174f2Safresh1For modern Windows releases, the major and minor version numbers are 1207*eac174f2Safresh1identical. The PRODUCTTYPE field must be used to differentiate between 1208*eac174f2Safresh1Windows 10 and Server releases. The BUILD field is used to 1209*eac174f2Safresh1differentiate Windows Server versions: currently 2016, 2019, and 1210*eac174f2Safresh1Semi-Annual Channel releases. 1211*eac174f2Safresh1 12126fb12b70Safresh1SPMAJOR and SPMINOR are the version numbers of the latest 1213*eac174f2Safresh1installed service pack. (In the Windows 10 era, these are unused.) 1214b39c5158Smillert 1215b39c5158SmillertSUITEMASK is a bitfield identifying the product suites available on 1216b39c5158Smillertthe system. Known bits are: 1217b39c5158Smillert 1218b39c5158Smillert VER_SUITE_SMALLBUSINESS 0x00000001 1219b39c5158Smillert VER_SUITE_ENTERPRISE 0x00000002 1220b39c5158Smillert VER_SUITE_BACKOFFICE 0x00000004 1221b39c5158Smillert VER_SUITE_COMMUNICATIONS 0x00000008 1222b39c5158Smillert VER_SUITE_TERMINAL 0x00000010 1223b39c5158Smillert VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020 1224b39c5158Smillert VER_SUITE_EMBEDDEDNT 0x00000040 1225b39c5158Smillert VER_SUITE_DATACENTER 0x00000080 1226b39c5158Smillert VER_SUITE_SINGLEUSERTS 0x00000100 1227b39c5158Smillert VER_SUITE_PERSONAL 0x00000200 1228b39c5158Smillert VER_SUITE_BLADE 0x00000400 1229b39c5158Smillert VER_SUITE_EMBEDDED_RESTRICTED 0x00000800 1230b39c5158Smillert VER_SUITE_SECURITY_APPLIANCE 0x00001000 1231898184e3Ssthen VER_SUITE_STORAGE_SERVER 0x00002000 1232898184e3Ssthen VER_SUITE_COMPUTE_SERVER 0x00004000 1233898184e3Ssthen VER_SUITE_WH_SERVER 0x00008000 1234*eac174f2Safresh1 VER_SUITE_MULTIUSERTS 0x00020000 1235b39c5158Smillert 1236b39c5158SmillertThe VER_SUITE_xxx names are listed here to cross reference the Microsoft 1237b39c5158Smillertdocumentation. The Win32 module does not provide symbolic names for these 1238b39c5158Smillertconstants. 1239b39c5158Smillert 1240b39c5158SmillertPRODUCTTYPE provides additional information about the system. It should 1241b39c5158Smillertbe one of the following integer values: 1242b39c5158Smillert 124391f110e0Safresh1 1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro, Vista, etc) 1244b39c5158Smillert 2 - Domaincontroller 124591f110e0Safresh1 3 - Server (2000 Server, Server 2003, Server 2008, etc) 1246b39c5158Smillert 1247b39c5158SmillertNote that a server that is also a domain controller is reported as 1248b39c5158SmillertPRODUCTTYPE 2 (Domaincontroller) and not PRODUCTTYPE 3 (Server). 1249b39c5158Smillert 1250b39c5158Smillert=item Win32::GetShortPathName(PATHNAME) 1251b39c5158Smillert 1252b39c5158Smillert[CORE] Returns a representation of PATHNAME that is composed of short 1253b39c5158Smillert(8.3) path components where available. For path components where the 1254b39c5158Smillertfile system has not generated the short form the returned path will 1255b39c5158Smillertuse the long form, so this function might still for instance return a 1256b39c5158Smillertpath containing spaces. Returns C<undef> when the PATHNAME does not 1257b39c5158Smillertexist. Compare with Win32::GetFullPathName() and 1258b39c5158SmillertWin32::GetLongPathName(). 1259b39c5158Smillert 1260898184e3Ssthen=item Win32::GetSystemMetrics(INDEX) 1261898184e3Ssthen 1262898184e3SsthenRetrieves the specified system metric or system configuration setting. 1263898184e3SsthenPlease refer to the Microsoft documentation of the GetSystemMetrics() 1264898184e3Ssthenfunction for a reference of available INDEX values. All system 1265898184e3Ssthenmetrics return integer values. 1266898184e3Ssthen 1267b39c5158Smillert=item Win32::GetProcAddress(INSTANCE, PROCNAME) 1268b39c5158Smillert 1269b39c5158SmillertReturns the address of a function inside a loaded library. The 1270b39c5158Smillertinformation about what you can do with this address has been lost in 1271b39c5158Smillertthe mist of time. Use the Win32::API module instead of this deprecated 1272b39c5158Smillertfunction. 1273b39c5158Smillert 1274*eac174f2Safresh1=item Win32::GetProcessPrivileges([PID]) 1275*eac174f2Safresh1 1276*eac174f2Safresh1Returns a reference to a hash holding the information about the privileges 1277*eac174f2Safresh1held by the specified process. The keys are privilege names, and the values 1278*eac174f2Safresh1are booleans indicating whether a given privilege is currently enabled or not. 1279*eac174f2Safresh1 1280*eac174f2Safresh1If the optional PID parameter is omitted, the function queries the current 1281*eac174f2Safresh1process. 1282*eac174f2Safresh1 1283*eac174f2Safresh1Example return value: 1284*eac174f2Safresh1 1285*eac174f2Safresh1 { 1286*eac174f2Safresh1 SeTimeZonePrivilege => 0, 1287*eac174f2Safresh1 SeShutdownPrivilege => 0, 1288*eac174f2Safresh1 SeUndockPrivilege => 0, 1289*eac174f2Safresh1 SeIncreaseWorkingSetPrivilege => 0, 1290*eac174f2Safresh1 SeChangeNotifyPrivilege => 1 1291*eac174f2Safresh1 } 1292*eac174f2Safresh1 1293898184e3Ssthen=item Win32::GetProductInfo(OSMAJOR, OSMINOR, SPMAJOR, SPMINOR) 1294898184e3Ssthen 1295898184e3SsthenRetrieves the product type for the operating system on the local 1296898184e3Ssthencomputer, and maps the type to the product types supported by the 1297898184e3Ssthenspecified operating system. Please refer to the Microsoft 1298898184e3Ssthendocumentation of the GetProductInfo() function for more information 1299898184e3Ssthenabout the parameters and return value. This function requires Windows 1300898184e3SsthenVista or later. 1301898184e3Ssthen 1302898184e3SsthenSee also the Win32::GetOSName() and Win32::GetOSDisplayName() 1303898184e3Ssthenfunctions which provide a higher level abstraction of the data 1304898184e3Ssthenreturned by this function. 1305898184e3Ssthen 1306b39c5158Smillert=item Win32::GetTickCount() 1307b39c5158Smillert 1308b39c5158Smillert[CORE] Returns the number of milliseconds elapsed since the last 1309b39c5158Smillertsystem boot. Resolution is limited to system timer ticks (about 10ms 1310b39c5158Smillerton WinNT and 55ms on Win9X). 1311b39c5158Smillert 1312b39c5158Smillert=item Win32::GuidGen() 1313b39c5158Smillert 1314b39c5158SmillertCreates a globally unique 128 bit integer that can be used as a 1315b39c5158Smillertpersistent identifier in a distributed setting. To a very high degree 1316b39c5158Smillertof certainty this function returns a unique value. No other 1317b39c5158Smillertinvocation, on the same or any other system (networked or not), should 1318b39c5158Smillertreturn the same value. 1319b39c5158Smillert 1320b39c5158SmillertThe return value is formatted according to OLE conventions, as groups 1321b39c5158Smillertof hex digits with surrounding braces. For example: 1322b39c5158Smillert 1323b39c5158Smillert {09531CF1-D0C7-4860-840C-1C8C8735E2AD} 1324b39c5158Smillert 1325*eac174f2Safresh1=item Win32::HttpGetFile(URL, FILENAME [, IGNORE_CERT_ERRORS]) 1326*eac174f2Safresh1 1327*eac174f2Safresh1Uses the WinHttp library to download the file specified by the URL 1328*eac174f2Safresh1parameter to the local file specified by FILENAME. The optional third 1329*eac174f2Safresh1parameter, if true, indicates that certficate errors are to be ignored 1330*eac174f2Safresh1for https connections; please use with caution in a safe environment, 1331*eac174f2Safresh1such as when testing locally using a self-signed certificate. 1332*eac174f2Safresh1 1333*eac174f2Safresh1Only http and https protocols are supported. Authentication is not 1334*eac174f2Safresh1supported. The function is not available when building with gcc prior to 1335*eac174f2Safresh14.8.0 because the WinHttp library is not available. 1336*eac174f2Safresh1 1337*eac174f2Safresh1In scalar context returns a boolean success or failure, and in list 1338*eac174f2Safresh1context also returns, in addition to the boolean status, a second 1339*eac174f2Safresh1value containing message text related to the status. 1340*eac174f2Safresh1 1341*eac174f2Safresh1If the call fails, C<Win32::GetLastError()> will return a numeric 1342*eac174f2Safresh1error code, which may be a system error, a WinHttp error, or a 1343*eac174f2Safresh1user-defined error composed of 1e9 plus the HTTP status code. 1344*eac174f2Safresh1 1345*eac174f2Safresh1Scalar context example: 1346*eac174f2Safresh1 1347*eac174f2Safresh1 print Win32::GetLastError() 1348*eac174f2Safresh1 unless Win32::HttpGetFile('http://example.com/somefile.tar.gz', 1349*eac174f2Safresh1 '.\file.tgz'); 1350*eac174f2Safresh1 1351*eac174f2Safresh1List context example: 1352*eac174f2Safresh1 1353*eac174f2Safresh1 my ($ok, $msg) = Win32::HttpGetFile('http://example.com/somefile.tar.gz', 1354*eac174f2Safresh1 '.\file.tgz'); 1355*eac174f2Safresh1 if ($ok) { 1356*eac174f2Safresh1 print "Success!: $msg\n"; 1357*eac174f2Safresh1 } 1358*eac174f2Safresh1 else { 1359*eac174f2Safresh1 print "Failure!: $msg\n"; 1360*eac174f2Safresh1 my $err = Win32::GetLastError(); 1361*eac174f2Safresh1 if ($err > 1e9) { 1362*eac174f2Safresh1 printf "HTTP status: %d\n", ($err - 1e9); 1363*eac174f2Safresh1 } 1364*eac174f2Safresh1 } 1365*eac174f2Safresh1 1366b39c5158Smillert=item Win32::InitiateSystemShutdown 1367b39c5158Smillert 1368b39c5158Smillert(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT) 1369b39c5158Smillert 1370b39c5158SmillertShuts down the specified MACHINE, notifying users with the 1371b39c5158Smillertsupplied MESSAGE, within the specified TIMEOUT interval. Forces 1372b39c5158Smillertclosing of all documents without prompting the user if FORCECLOSE is 1373b39c5158Smillerttrue, and reboots the machine if REBOOT is true. This function works 1374b39c5158Smillertonly on WinNT. 1375b39c5158Smillert 1376b39c5158Smillert=item Win32::IsAdminUser() 1377b39c5158Smillert 1378b39c5158SmillertReturns non zero if the account in whose security context the 1379b39c5158Smillertcurrent process/thread is running belongs to the local group of 1380b39c5158SmillertAdministrators in the built-in system domain; returns 0 if not. 1381b39c5158SmillertOn Windows Vista it will only return non-zero if the process is 1382b39c5158Smillertactually running with elevated privileges. Returns C<undef> 1383b39c5158Smillertand prints a warning if an error occurred. This function always 1384b39c5158Smillertreturns 1 on Win9X. 1385b39c5158Smillert 1386*eac174f2Safresh1=item Win32::IsDeveloperModeEnabled() 1387*eac174f2Safresh1 1388*eac174f2Safresh1Returns true if the developer mode is currently enabled. It always returns 1389*eac174f2Safresh1false on Windows versions older than Windows 10. 1390*eac174f2Safresh1 1391*eac174f2Safresh1=item Win32::IsSymlinkCreationAllowed() 1392*eac174f2Safresh1 1393*eac174f2Safresh1Returns true if the current process is allowed to create symbolic links. This 1394*eac174f2Safresh1function is a convenience wrapper around Win32::GetProcessPrivileges() and 1395*eac174f2Safresh1Win32::IsDeveloperModeEnabled(). 1396*eac174f2Safresh1 1397b39c5158Smillert=item Win32::IsWinNT() 1398b39c5158Smillert 1399b39c5158Smillert[CORE] Returns non zero if the Win32 subsystem is Windows NT. 1400b39c5158Smillert 1401b39c5158Smillert=item Win32::IsWin95() 1402b39c5158Smillert 1403b39c5158Smillert[CORE] Returns non zero if the Win32 subsystem is Windows 95. 1404b39c5158Smillert 1405b39c5158Smillert=item Win32::LoadLibrary(LIBNAME) 1406b39c5158Smillert 1407b39c5158SmillertLoads a dynamic link library into memory and returns its module 1408b39c5158Smillerthandle. This handle can be used with Win32::GetProcAddress() and 1409b39c5158SmillertWin32::FreeLibrary(). This function is deprecated. Use the Win32::API 1410b39c5158Smillertmodule instead. 1411b39c5158Smillert 1412b39c5158Smillert=item Win32::LoginName() 1413b39c5158Smillert 1414b39c5158Smillert[CORE] Returns the username of the owner of the current perl process. 1415b39c5158SmillertThe return value may be a Unicode string. 1416b39c5158Smillert 1417b39c5158Smillert=item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE) 1418b39c5158Smillert 1419b39c5158SmillertLooks up ACCOUNT on SYSTEM and returns the domain name the SID and 1420b39c5158Smillertthe SID type. 1421b39c5158Smillert 1422b39c5158Smillert=item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE) 1423b39c5158Smillert 1424b39c5158SmillertLooks up SID on SYSTEM and returns the account name, domain name, 1425b39c5158Smillertand the SID type. 1426b39c5158Smillert 1427b39c5158Smillert=item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]]) 1428b39c5158Smillert 1429b39c5158SmillertCreate a dialog box containing MESSAGE. FLAGS specifies the 1430b39c5158Smillertrequired icon and buttons according to the following table: 1431b39c5158Smillert 1432b39c5158Smillert 0 = OK 1433b39c5158Smillert 1 = OK and Cancel 1434b39c5158Smillert 2 = Abort, Retry, and Ignore 1435b39c5158Smillert 3 = Yes, No and Cancel 1436b39c5158Smillert 4 = Yes and No 1437b39c5158Smillert 5 = Retry and Cancel 1438b39c5158Smillert 1439b39c5158Smillert MB_ICONSTOP "X" in a red circle 1440b39c5158Smillert MB_ICONQUESTION question mark in a bubble 1441b39c5158Smillert MB_ICONEXCLAMATION exclamation mark in a yellow triangle 1442b39c5158Smillert MB_ICONINFORMATION "i" in a bubble 1443b39c5158Smillert 1444b39c5158SmillertTITLE specifies an optional window title. The default is "Perl". 1445b39c5158Smillert 1446b39c5158SmillertThe function returns the menu id of the selected push button: 1447b39c5158Smillert 1448b39c5158Smillert 0 Error 1449b39c5158Smillert 1450b39c5158Smillert 1 OK 1451b39c5158Smillert 2 Cancel 1452b39c5158Smillert 3 Abort 1453b39c5158Smillert 4 Retry 1454b39c5158Smillert 5 Ignore 1455b39c5158Smillert 6 Yes 1456b39c5158Smillert 7 No 1457b39c5158Smillert 1458b39c5158Smillert=item Win32::NodeName() 1459b39c5158Smillert 1460b39c5158Smillert[CORE] Returns the Microsoft Network node-name of the current machine. 1461b39c5158Smillert 1462b39c5158Smillert=item Win32::OutputDebugString(STRING) 1463b39c5158Smillert 1464b39c5158SmillertSends a string to the application or system debugger for display. 1465b39c5158SmillertThe function does nothing if there is no active debugger. 1466b39c5158Smillert 1467b39c5158SmillertAlternatively one can use the I<Debug Viewer> application to 1468b39c5158Smillertwatch the OutputDebugString() output: 1469b39c5158Smillert 1470b39c5158Smillerthttp://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx 1471b39c5158Smillert 1472b39c5158Smillert=item Win32::RegisterServer(LIBRARYNAME) 1473b39c5158Smillert 1474b39c5158SmillertLoads the DLL LIBRARYNAME and calls the function DllRegisterServer. 1475b39c5158Smillert 1476b39c5158Smillert=item Win32::SetChildShowWindow(SHOWWINDOW) 1477b39c5158Smillert 1478b39c5158Smillert[CORE] Sets the I<ShowMode> of child processes started by system(). 1479b39c5158SmillertBy default system() will create a new console window for child 1480b39c5158Smillertprocesses if Perl itself is not running from a console. Calling 1481b39c5158SmillertSetChildShowWindow(0) will make these new console windows invisible. 1482b39c5158SmillertCalling SetChildShowWindow() without arguments reverts system() to the 1483b39c5158Smillertdefault behavior. The return value of SetChildShowWindow() is the 1484b39c5158Smillertprevious setting or C<undef>. 1485b39c5158Smillert 1486b39c5158SmillertThe following symbolic constants for SHOWWINDOW are available 1487b39c5158Smillert(but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL, 1488b39c5158SmillertSW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE. 1489b39c5158Smillert 149091f110e0Safresh1=item Win32::SetConsoleCP(ID) 149191f110e0Safresh1 149291f110e0Safresh1Sets the input code page used by the console associated with the 149391f110e0Safresh1calling process. The return value of SetConsoleCP() is nonzero on 149491f110e0Safresh1success or zero on failure. To get the console's input code page, see 149591f110e0Safresh1GetConsoleCP(). 149691f110e0Safresh1 149791f110e0Safresh1=item Win32::SetConsoleOutputCP(ID) 149891f110e0Safresh1 149991f110e0Safresh1Sets the output code page used by the console associated with the 150091f110e0Safresh1calling process. The return value of SetConsoleOutputCP() is nonzero on 150191f110e0Safresh1success or zero on failure. To get the console's output code page, see 150291f110e0Safresh1GetConsoleOutputCP(). 150391f110e0Safresh1 1504b39c5158Smillert=item Win32::SetCwd(NEWDIRECTORY) 1505b39c5158Smillert 1506b39c5158Smillert[CORE] Sets the current active drive and directory. This function does not 1507b39c5158Smillertwork with UNC paths, since the functionality required to required for 1508b39c5158Smillertsuch a feature is not available under Windows 95. 1509b39c5158Smillert 1510b39c5158Smillert=item Win32::SetLastError(ERROR) 1511b39c5158Smillert 1512b39c5158Smillert[CORE] Sets the value of the last error encountered to ERROR. This is 1513b39c5158Smillertthat value that will be returned by the Win32::GetLastError() 1514b39c5158Smillertfunction. 1515b39c5158Smillert 1516b39c5158Smillert=item Win32::Sleep(TIME) 1517b39c5158Smillert 1518b39c5158Smillert[CORE] Pauses for TIME milliseconds. The timeslices are made available 1519b39c5158Smillertto other processes and threads. 1520b39c5158Smillert 1521b39c5158Smillert=item Win32::Spawn(COMMAND, ARGS, PID) 1522b39c5158Smillert 1523b39c5158Smillert[CORE] Spawns a new process using the supplied COMMAND, passing in 1524b39c5158Smillertarguments in the string ARGS. The pid of the new process is stored in 1525b39c5158SmillertPID. This function is deprecated. Please use the Win32::Process module 1526b39c5158Smillertinstead. 1527b39c5158Smillert 1528b39c5158Smillert=item Win32::UnregisterServer(LIBRARYNAME) 1529b39c5158Smillert 1530b39c5158SmillertLoads the DLL LIBRARYNAME and calls the function 1531b39c5158SmillertDllUnregisterServer. 1532b39c5158Smillert 1533b39c5158Smillert=back 1534b39c5158Smillert 1535*eac174f2Safresh1=head1 CAVEATS 1536*eac174f2Safresh1 1537*eac174f2Safresh1=head2 Short Path Names 1538*eac174f2Safresh1 1539*eac174f2Safresh1There are many situations in which modern Windows systems will not have 1540*eac174f2Safresh1the L<short path name|https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#short-vs-long-names> 1541*eac174f2Safresh1(also called 8.3 or MS-DOS) alias for long file names available. 1542*eac174f2Safresh1 1543*eac174f2Safresh1Short path support can be configured system-wide via the registry, 1544*eac174f2Safresh1but the default on modern systems is to configure short path usage per 1545*eac174f2Safresh1volume. The configuration for a volume can be queried in a number of ways, 1546*eac174f2Safresh1but these may either be unreliable or require elevated (administrator) 1547*eac174f2Safresh1privileges. 1548*eac174f2Safresh1 1549*eac174f2Safresh1Typically, the configuration for a volume can be queried using the C<fsutil> 1550*eac174f2Safresh1utility, e.g. C<fsutil 8dot3name query d:>. On the C level, it can be queried 1551*eac174f2Safresh1with a C<FSCTL_QUERY_PERSISTENT_VOLUME_STATE> request to the 1552*eac174f2Safresh1C<DeviceIOControl> API call, as described in 1553*eac174f2Safresh1L<this article|https://www.codeproject.com/Articles/304374/Query-Volume-Setting-for-State-Windows>. 1554*eac174f2Safresh1However, both of these methods require administrator privileges to work. 1555*eac174f2Safresh1 1556*eac174f2Safresh1The Win32 module does not perform any per-volume check and simply fetches 1557*eac174f2Safresh1short path names in the same manner as the underlying Windows API call it 1558*eac174f2Safresh1uses: If short path names are disabled, the call will still succeed but the 1559*eac174f2Safresh1long name will actually be returned. 1560*eac174f2Safresh1 1561*eac174f2Safresh1Note that on volumes where this happens, C<GetANSIPathName> usually cannot be 1562*eac174f2Safresh1used to return useful filenames for files that contain unicode characters. 1563*eac174f2Safresh1(In code page 65001, this may still work.) Handling unicode filenames in this 1564*eac174f2Safresh1legacy manner relies upon C<GetShortPathName> returning 8.3 filenames, but 1565*eac174f2Safresh1without short name support, it will return the filename with all unicode 1566*eac174f2Safresh1characters replaced by question mark characters. 1567*eac174f2Safresh1 1568b39c5158Smillert=cut 1569