Changeset 1874
- Timestamp:
- 3/1/2010 12:29:44 PM (2 years ago)
- Location:
- trunk/eraser6/Eraser.Util
- Files:
-
- 3 edited
-
BlackBox.cs (modified) (3 diffs)
-
NativeMethods/Kernel.cs (modified) (1 diff)
-
SystemInfo.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.Util/BlackBox.cs
r1842 r1874 40 40 using System.Net; 41 41 using System.Xml; 42 using System.ComponentModel; 42 43 43 44 namespace Eraser.Util … … 189 190 //Application information 190 191 string separator = new string('-', 76); 191 string lineFormat = "{0,1 5}: {1}";192 string lineFormat = "{0,17}: {1}"; 192 193 stream.WriteLine("Application Information"); 193 194 stream.WriteLine(separator); … … 202 203 stream.WriteLine(string.Format(lineFormat, "Command Line", 203 204 commandLine.ToString().Trim())); 205 stream.WriteLine(string.Format(lineFormat, "Current Directory", 206 Environment.CurrentDirectory)); 207 208 //System Information 209 stream.WriteLine(); 210 stream.WriteLine("System Information"); 211 stream.WriteLine(separator); 212 stream.WriteLine(string.Format(lineFormat, "Operating System", 213 string.Format("{0} {2} {3}{1}", 214 Environment.OSVersion.VersionString, 215 string.IsNullOrEmpty(Environment.OSVersion.ServicePack) ? 216 string.Empty : 217 string.Format("(Service Pack {2})", Environment.OSVersion.ServicePack), 218 SystemInfo.WindowsEdition == WindowsEditions.Undefined ? 219 "" : SystemInfo.WindowsEdition.ToString(), 220 SystemInfo.ProcessorArchitecture))); 221 stream.WriteLine(string.Format(lineFormat, "Processor Count", 222 Environment.ProcessorCount)); 223 224 //Running processes 225 stream.WriteLine(); 226 stream.WriteLine("Running Processes"); 227 stream.WriteLine(separator); 228 { 229 int i = 0; 230 foreach (Process process in Process.GetProcesses()) 231 { 232 try 233 { 234 ProcessModule mainModule = process.MainModule; 235 stream.WriteLine(string.Format(lineFormat, 236 string.Format("Process[{0}]", ++i), 237 string.Format("{0} [{1}.{2}.{3}.{4}{5}]", mainModule.FileName, 238 mainModule.FileVersionInfo.FileMajorPart, 239 mainModule.FileVersionInfo.FileMinorPart, 240 mainModule.FileVersionInfo.FileBuildPart, 241 mainModule.FileVersionInfo.FilePrivatePart, 242 string.IsNullOrEmpty(mainModule.FileVersionInfo.FileVersion) ? 243 string.Empty : 244 string.Format(" <{0}>", 245 mainModule.FileVersionInfo.FileVersion)))); 246 } 247 catch (Win32Exception) 248 { 249 } 250 } 251 } 204 252 205 253 //Exception Information -
trunk/eraser6/Eraser.Util/NativeMethods/Kernel.cs
r1859 r1874 860 860 public const int MaxPath = 260; 861 861 public const int LongPath = 32768; 862 863 /// <summary> 864 /// Retrieves the product type for the operating system on the local computer, and 865 /// maps the type to the product types supported by the specified operating system. 866 /// </summary> 867 /// <param name="dwOSMajorVersion">The major version number of the operating system. 868 /// The minimum value is 6. 869 /// 870 /// The combination of the dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, 871 /// and dwSpMinorVersion parameters describes the maximum target operating system 872 /// version for the application. For example, Windows Vista and Windows Server 873 /// 2008 are version 6.0.0.0 and Windows 7 and Windows Server 2008 R2 are version 874 /// 6.1.0.0.</param> 875 /// <param name="dwOSMinorVersion">The minor version number of the operating 876 /// system. The minimum value is 0.</param> 877 /// <param name="dwSpMajorVersion">The major version number of the operating 878 /// system service pack. The minimum value is 0.</param> 879 /// <param name="dwSpMinorVersion">The minor version number of the operating 880 /// system service pack. The minimum value is 0.</param> 881 /// <param name="pdwReturnedProductType">The product type. This parameter 882 /// cannot be NULL. If the specified operating system is less than the 883 /// current operating system, this information is mapped to the types 884 /// supported by the specified operating system. If the specified operating 885 /// system is greater than the highest supported operating system, this 886 /// information is mapped to the types supported by the current operating system. 887 /// 888 /// If the product has not been activated and is no longer in the grace period, 889 /// this parameter is set to PRODUCT_UNLICENSED (0xABCDABCD).</param> 890 /// <returns>If the function succeeds, the return value is a nonzero value. 891 /// If the software license is invalid or expired, the function succeeds 892 /// but the pdwReturnedProductType parameter is set to PRODUCT_UNLICENSED. 893 /// 894 /// If the function fails, the return value is zero. This function fails if 895 /// one of the input parameters is invalid.</returns> 896 [DllImport("Kernel32.dll", CharSet = CharSet.Unicode)] 897 public static extern bool GetProductInfo(uint dwOSMajorVersion, 898 uint dwOSMinorVersion, uint dwSpMajorVersion, uint dwSpMinorVersion, 899 out WindowsEditions pdwReturnedProductType); 900 862 901 } 863 902 } -
trunk/eraser6/Eraser.Util/SystemInfo.cs
r1802 r1874 70 70 } 71 71 } 72 73 /// <summary> 74 /// Gets the edition of Windows that is currently running. This will only 75 /// return a valid result for operating systems later than or equal to 76 /// Windows Vista (RTM). All other operating systems will return 77 /// <see cref="WindowsEditions.Undefined"/>. 78 /// </summary> 79 public static WindowsEditions WindowsEdition 80 { 81 get 82 { 83 if (Environment.OSVersion.Platform != PlatformID.Win32NT || 84 Environment.OSVersion.Version.Major < 6) 85 { 86 return WindowsEditions.Undefined; 87 } 88 89 WindowsEditions result; 90 NativeMethods.GetProductInfo(6u, 1u, 0u, 0u, out result); 91 return result; 92 } 93 } 94 } 95 96 public enum WindowsEditions 97 { 98 /// <summary> 99 /// Business 100 /// </summary> 101 Business = 0x00000006, 102 103 /// <summary> 104 /// Business N 105 /// </summary> 106 BusinessN = 0x00000010, 107 108 /// <summary> 109 /// HPC Edition 110 /// </summary> 111 ClusterServer = 0x00000012, 112 113 /// <summary> 114 /// Server Datacenter (full installation) 115 /// </summary> 116 DatacenterServer = 0x00000008, 117 118 /// <summary> 119 /// Server Datacenter (core installation) 120 /// </summary> 121 DatacenterServerCore = 0x0000000C, 122 123 /// <summary> 124 /// Server Datacenter without Hyper-V (core installation) 125 /// </summary> 126 DatacenterServerCoreV = 0x00000027, 127 128 /// <summary> 129 /// Server Datacenter without Hyper-V (full installation) 130 /// </summary> 131 DatacenterServerV = 0x00000025, 132 133 /// <summary> 134 /// Enterprise 135 /// </summary> 136 Enterprise = 0x00000004, 137 138 /// <summary> 139 /// Enterprise E 140 /// </summary> 141 EnterpriseE = 0x00000046, 142 143 /// <summary> 144 /// Enterprise N 145 /// </summary> 146 EnterpriseN = 0x0000001B, 147 148 /// <summary> 149 /// Server Enterprise (full installation) 150 /// </summary> 151 EnterpriseServer = 0x0000000A, 152 153 /// <summary> 154 /// Server Enterprise (core installation) 155 /// </summary> 156 EnterpriseServerCore = 0x0000000E, 157 158 /// <summary> 159 /// Server Enterprise without Hyper-V (core installation) 160 /// </summary> 161 EnterpriseServerCoreV = 0x00000029, 162 163 /// <summary> 164 /// Server Enterprise for Itanium-based Systems 165 /// </summary> 166 EnterpriseServerIA64 = 0x0000000F, 167 168 /// <summary> 169 /// Server Enterprise without Hyper-V (full installation) 170 /// </summary> 171 EnterpriseServerV = 0x00000026, 172 173 /// <summary> 174 /// Home Basic 175 /// </summary> 176 HomeBasic = 0x00000002, 177 178 /// <summary> 179 /// Home Basic E 180 /// </summary> 181 HomeBasicE = 0x00000043, 182 183 /// <summary> 184 /// Home Basic N 185 /// </summary> 186 HomeBasicN = 0x00000005, 187 188 /// <summary> 189 /// Home Premium 190 /// </summary> 191 HomePremium = 0x00000003, 192 193 /// <summary> 194 /// Home Premium E 195 /// </summary> 196 HomePremiumE = 0x00000044, 197 198 /// <summary> 199 /// Home Premium N 200 /// </summary> 201 HomePremiumN = 0x0000001A, 202 203 /// <summary> 204 /// Microsoft Hyper-V Server 205 /// </summary> 206 HyperV = 0x0000002A, 207 208 /// <summary> 209 /// Windows Essential Business Server Management Server 210 /// </summary> 211 MediumBusinessServerManagement = 0x0000001E, 212 213 /// <summary> 214 /// Windows Essential Business Server Messaging Server 215 /// </summary> 216 MediumBusinessServerMessaging = 0x00000020, 217 218 /// <summary> 219 /// Windows Essential Business Server Security Server 220 /// </summary> 221 MediumBusinessServerSecurity = 0x0000001F, 222 223 /// <summary> 224 /// Professional 225 /// </summary> 226 Professional = 0x00000030, 227 228 /// <summary> 229 /// Professional E 230 /// </summary> 231 ProfessionalE = 0x00000045, 232 233 /// <summary> 234 /// Professional N 235 /// </summary> 236 ProfessionalN = 0x00000031, 237 238 /// <summary> 239 /// Windows Server 2008 for Windows Essential Server Solutions 240 /// </summary> 241 ServerForSmallBusiness = 0x00000018, 242 243 /// <summary> 244 /// Windows Server 2008 without Hyper-V for Windows Essential Server Solutions 245 /// </summary> 246 ServerForSmallBusinessV = 0x00000023, 247 248 /// <summary> 249 /// Server Foundation 250 /// </summary> 251 ServerFoundation = 0x00000021, 252 253 /// <summary> 254 /// Windows Small Business Server 255 /// </summary> 256 SmallBusinessServer = 0x00000009, 257 258 /// <summary> 259 /// Server Standard (full installation) 260 /// </summary> 261 StandardServer = 0x00000007, 262 263 /// <summary> 264 /// Server Standard (core installation) 265 /// </summary> 266 StandardServerCore = 0x0000000D, 267 268 /// <summary> 269 /// Server Standard without Hyper-V (core installation) 270 /// </summary> 271 StandardServerCoreV = 0x00000028, 272 273 /// <summary> 274 /// Server Standard without Hyper-V (full installation) 275 /// </summary> 276 StandardServerV = 0x00000024, 277 278 /// <summary> 279 /// Starter 280 /// </summary> 281 Starter = 0x0000000B, 282 283 /// <summary> 284 /// Starter E 285 /// </summary> 286 StarterE = 0x00000042, 287 288 /// <summary> 289 /// Starter N 290 /// </summary> 291 StarterN = 0x0000002F, 292 293 /// <summary> 294 /// Storage Server Enterprise 295 /// </summary> 296 StorageEnterpriseServer = 0x00000017, 297 298 /// <summary> 299 /// Storage Server Express 300 /// </summary> 301 StorageExpressServer = 0x00000014, 302 303 /// <summary> 304 /// Storage Server Standard 305 /// </summary> 306 StorageStandardServer = 0x00000015, 307 308 /// <summary> 309 /// Storage Server Workgroup 310 /// </summary> 311 StorageWorkgroupServer = 0x00000016, 312 313 /// <summary> 314 /// An unknown product 315 /// </summary> 316 Undefined = 0x00000000, 317 318 /// <summary> 319 /// Ultimate 320 /// </summary> 321 Ultimate = 0x00000001, 322 323 /// <summary> 324 /// Ultimate E 325 /// </summary> 326 UltimateE = 0x00000047, 327 328 /// <summary> 329 /// Ultimate N 330 /// </summary> 331 UltimateN = 0x0000001C, 332 333 /// <summary> 334 /// Web Server (full installation) 335 /// </summary> 336 WebServer = 0x00000011, 337 338 /// <summary> 339 /// Web Server (core installation) 340 /// </summary> 341 WebServerCore = 0x0000001D 72 342 } 73 343 }
Note: See TracChangeset
for help on using the changeset viewer.
