Advertisement
sandrovieira

Untitled

Nov 15th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. namespace ConsoleApplication1
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             string str2 = "";
  8.             ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor");
  9.             UInt32 x;
  10.             foreach (ManagementObject share in searcher.Get())
  11.             {
  12.                 foreach (PropertyData PC in share.Properties)
  13.                 {
  14.                     str2 = PC.Name;
  15.                     if (PC.Value != null)
  16.                     {
  17.                         switch (PC.Value.GetType().ToString())
  18.                         {
  19.                             case "System.String":
  20.                                 str2 += " = " + (string)PC.Value;
  21.  
  22.                                 break;
  23.                             case "System.UInt16":
  24.                                 ushort shortData = (ushort)PC.Value;
  25.  
  26.                                 str2 += "=" + shortData.ToString();
  27.                                 break;
  28.                             case "System.UInt32":
  29.                                 UInt32 longData = (UInt32)PC.Value;
  30.  
  31.                                 str2 += "=" + longData.ToString();
  32.                                 break;
  33.                             default:
  34.                                 str2 += " = " + (string)PC.Value;
  35.                                 break;
  36.  
  37.                         }
  38.                     }
  39.                     Console.WriteLine("\n{0:s}", str2);
  40.                 }
  41.                 Console.ReadKey();
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement