Advertisement
tolikpunkoff

generate unique computer identifier sample

May 5th, 2018
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1.  public static class cCHID
  2.     {
  3.         public static string GetCHID()
  4.         {
  5.             string CHID = "";
  6.  
  7.             ManagementObjectSearcher searcher;
  8.  
  9.             //processor
  10.             searcher = new ManagementObjectSearcher("root\\CIMV2",
  11.                    "SELECT * FROM Win32_Processor");
  12.             foreach (ManagementObject queryObj in searcher.Get())
  13.                 CHID = CHID + queryObj["ProcessorId"].ToString() + "_";
  14.  
  15.             //mainboard id
  16.             searcher = new ManagementObjectSearcher("root\\CIMV2",
  17.                    "SELECT * FROM CIM_Card");
  18.             foreach (ManagementObject queryObj in searcher.Get())
  19.                 CHID = CHID + queryObj["SerialNumber"].ToString() + "_";
  20.  
  21.             //OS serial number
  22.             searcher = new ManagementObjectSearcher("root\\CIMV2",
  23.                    "SELECT * FROM CIM_OperatingSystem");
  24.             foreach (ManagementObject queryObj in searcher.Get())
  25.                 CHID = CHID + queryObj["SerialNumber"].ToString();
  26.  
  27.             return CHID;
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement