Advertisement
bom6er

Untitled

Oct 24th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. Код вывода большого количества разной информации о операционной системе, в том числе ее версию, номер сервиспака, количества свободной памяти и многое другое:
  2. using System;
  3. using System.Management;
  4.  
  5. namespace test
  6. {
  7. class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11.         ManagementObjectSearcher searcher5 =
  12.         new ManagementObjectSearcher("root\\CIMV2",
  13.             "SELECT * FROM Win32_OperatingSystem");
  14.  
  15.         foreach (ManagementObject queryObj in searcher5.Get())
  16.         {
  17.             Console.WriteLine("-----------------------------------");
  18.             Console.WriteLine("Win32_OperatingSystem instance");
  19.             Console.WriteLine("-----------------------------------");
  20.             Console.WriteLine("BuildNumber: {0}", queryObj["BuildNumber"]);
  21.             Console.WriteLine("Caption: {0}", queryObj["Caption"]);
  22.             Console.WriteLine("FreePhysicalMemory: {0}", queryObj["FreePhysicalMemory"]);
  23.             Console.WriteLine("FreeVirtualMemory: {0}", queryObj["FreeVirtualMemory"]);
  24.             Console.WriteLine("Name: {0}", queryObj["Name"]);
  25.             Console.WriteLine("OSType: {0}", queryObj["OSType"]);
  26.             Console.WriteLine("RegisteredUser: {0}", queryObj["RegisteredUser"]);
  27.             Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);
  28.             Console.WriteLine("ServicePackMajorVersion: {0}", queryObj["ServicePackMajorVersion"]);
  29.             Console.WriteLine("ServicePackMinorVersion: {0}", queryObj["ServicePackMinorVersion"]);
  30.             Console.WriteLine("Status: {0}", queryObj["Status"]);
  31.             Console.WriteLine("SystemDevice: {0}", queryObj["SystemDevice"]);
  32.             Console.WriteLine("SystemDirectory: {0}", queryObj["SystemDirectory"]);
  33.             Console.WriteLine("SystemDrive: {0}", queryObj["SystemDrive"]);
  34.             Console.WriteLine("Version: {0}", queryObj["Version"]);
  35.             Console.WriteLine("WindowsDirectory: {0}", queryObj["WindowsDirectory"]);
  36.         }
  37.  
  38.         Console.Write("Press any key to continue . . . ");
  39.         Console.ReadKey(true);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement