Module: Windows::SystemInfo
- Defined in:
- lib/windows/system_info.rb
Constant Summary collapse
- PROCESSOR_INTEL_386 =
Obsolete processor info constants
386- PROCESSOR_INTEL_486 =
486- PROCESSOR_INTEL_PENTIUM =
586- PROCESSOR_INTEL_IA64 =
2200- PROCESSOR_AMD_X8664 =
8664- VER_SERVER_NT =
Suite mask constants
0x80000000- VER_WORKSTATION_NT =
0x40000000- VER_SUITE_SMALLBUSINESS =
0x00000001- VER_SUITE_ENTERPRISE =
0x00000002- VER_SUITE_BACKOFFICE =
0x00000004- VER_SUITE_COMMUNICATIONS =
0x00000008- VER_SUITE_TERMINAL =
0x00000010- VER_SUITE_SMALLBUSINESS_RESTRICTED =
0x00000020- VER_SUITE_EMBEDDEDNT =
0x00000040- VER_SUITE_DATACENTER =
0x00000080- VER_SUITE_SINGLEUSERTS =
0x00000100- VER_SUITE_PERSONAL =
0x00000200- VER_SUITE_BLADE =
0x00000400- VER_SUITE_EMBEDDED_RESTRICTED =
0x00000800- VER_SUITE_SECURITY_APPLIANCE =
0x00001000- VER_SUITE_STORAGE_SERVER =
0x00002000- VER_SUITE_COMPUTE_SERVER =
0x00004000- VER_NT_WORKSTATION =
Product mask constants
0x0000001- VER_NT_DOMAIN_CONTROLLER =
0x0000002- VER_NT_SERVER =
0x0000003- VER_PLATFORM_WIN32s =
Platform definitions
0- VER_PLATFORM_WIN32_WINDOWS =
1- VER_PLATFORM_WIN32_NT =
2- VER_MINORVERSION =
Version info type constants
0x0000001- VER_MAJORVERSION =
0x0000002- VER_BUILDNUMBER =
0x0000004- VER_PLATFORMID =
0x0000008- VER_SERVICEPACKMINOR =
0x0000010- VER_SERVICEPACKMAJOR =
0x0000020- VER_SUITENAME =
0x0000040- VER_PRODUCT_TYPE =
0x0000080- ComputerNameNetBIOS =
Enum COMPUTER_NAME_FORMAT
0- ComputerNameDnsHostname =
1- ComputerNameDnsDomain =
2- ComputerNameDnsFullyQualified =
3- ComputerNamePhysicalNetBIOS =
4- ComputerNamePhysicalDnsHostname =
5- ComputerNamePhysicalDnsDomain =
6- ComputerNamePhysicalDnsFullyQualified =
7- ComputerNameMax =
8
Instance Method Summary collapse
- #HIBYTE(w) ⇒ Object
- #HIWORD(l) ⇒ Object
- #LOBYTE(w) ⇒ Object
- #LOWORD(l) ⇒ Object
- #MAKELONG(a, b) ⇒ Object
-
#MAKEWORD(a, b) ⇒ Object
These macros are from windef.h, but I’ve put them here for now since they can be used in conjunction with some of the functions declared in this module.
-
#windows_2000? ⇒ Boolean
Returns true if the current platform is Vista (any variant) or Windows Server 2008, i.e.
-
#windows_2003? ⇒ Boolean
Returns true if the current platform is Windows 2003 (any version).
-
#windows_vista? ⇒ Boolean
Returns true if the current platform is Windows Vista (any variant) or Windows Server 2008, i.e.
-
#windows_xp? ⇒ Boolean
Returns true if the current platform is Windows XP or Windows XP Pro, i.e.
Instance Method Details
#HIBYTE(w) ⇒ Object
114 115 116 |
# File 'lib/windows/system_info.rb', line 114 def HIBYTE(w) w >> 8 end |
#HIWORD(l) ⇒ Object
106 107 108 |
# File 'lib/windows/system_info.rb', line 106 def HIWORD(l) l >> 16 end |
#LOBYTE(w) ⇒ Object
110 111 112 |
# File 'lib/windows/system_info.rb', line 110 def LOBYTE(w) w & 0xff end |
#LOWORD(l) ⇒ Object
102 103 104 |
# File 'lib/windows/system_info.rb', line 102 def LOWORD(l) l & 0xffff end |
#MAKELONG(a, b) ⇒ Object
98 99 100 |
# File 'lib/windows/system_info.rb', line 98 def MAKELONG(a, b) ((a & 0xffff) | (b & 0xffff)) << 16 end |
#MAKEWORD(a, b) ⇒ Object
These macros are from windef.h, but I’ve put them here for now since they can be used in conjunction with some of the functions declared in this module.
94 95 96 |
# File 'lib/windows/system_info.rb', line 94 def MAKEWORD(a, b) ((a & 0xff) | (b & 0xff)) << 8 end |
#windows_2000? ⇒ Boolean
Returns true if the current platform is Vista (any variant) or Windows Server 2008, i.e. major version 6, minor version 0.
123 124 125 126 |
# File 'lib/windows/system_info.rb', line 123 def windows_2000? version = GetVersion() LOBYTE(LOWORD(version)) == 5 && HIBYTE(LOWORD(version)) == 0 end |
#windows_2003? ⇒ Boolean
Returns true if the current platform is Windows 2003 (any version). i.e. major version 5, minor version 2. – Because of the exception for a 64-bit Windows XP Pro, we have to to do things the hard way. For version 2 we look for any of the suite masks that might be associated with Windows 2003. If we find any of them, assume it’s Windows 2003.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/windows/system_info.rb', line 178 def windows_2003? bool = false buf = 0.chr * 156 buf[0,4] = [buf.size].pack("L") # Set dwOSVersionInfoSize GetVersionEx(buf) major = buf[4,4].unpack("L")[0] minor = buf[8,4].unpack("L")[0] suite = buf[152,2].unpack("S")[0] # Make sure we exclude a 64-bit Windows XP Pro if major == 5 && minor == 2 if (suite & VER_SUITE_BLADE > 0) || (suite & VER_SUITE_COMPUTE_SERVER > 0) || (suite & VER_SUITE_DATACENTER > 0) || (suite & VER_SUITE_ENTERPRISE > 0) || (suite & VER_SUITE_STORAGE_SERVER > 0) then bool = true end end bool end |
#windows_vista? ⇒ Boolean
Returns true if the current platform is Windows Vista (any variant) or Windows Server 2008, i.e. major version 6, minor version 0.
208 209 210 211 |
# File 'lib/windows/system_info.rb', line 208 def windows_vista? version = GetVersion() LOBYTE(LOWORD(version)) == 6 && HIBYTE(LOWORD(version)) == 0 end |
#windows_xp? ⇒ Boolean
Returns true if the current platform is Windows XP or Windows XP Pro, i.e. major version 5, minor version 1 (or 2 in the case of a 64-bit Windows XP Pro). – Because of the exception for a 64-bit Windows XP Pro, we have to to do things the hard way. For version 2 we look for any of the suite masks that might be associated with Windows 2003. If we don’t find any of them, assume it’s Windows XP.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/windows/system_info.rb', line 137 def windows_xp? bool = false buf = 0.chr * 156 buf[0,4] = [buf.size].pack("L") # Set dwOSVersionInfoSize GetVersionEx(buf) major = buf[4,4].unpack("L")[0] minor = buf[8,4].unpack("L")[0] suite = buf[152,2].unpack("S")[0] # Make sure we detect a 64-bit Windows XP Pro if major == 5 if minor == 1 bool = true elsif minor == 2 if (suite & VER_SUITE_BLADE == 0) && (suite & VER_SUITE_COMPUTE_SERVER == 0) && (suite & VER_SUITE_DATACENTER == 0) && (suite & VER_SUITE_ENTERPRISE == 0) && (suite & VER_SUITE_STORAGE_SERVER == 0) then bool = true end else # Do nothing - already false end end bool end |