Exemplo n.º 1
0
 public static string GetWin32_ClassAllProperValues(WMI_ClassNames Win32_Class)
 {
     ManagementClass class2 = new ManagementClass(Win32_Class.ToString().Trim());
     string str = null;
     ManagementObjectCollection instances = class2.GetInstances();
     foreach (ManagementObject obj2 in instances)
     {
         str = obj2.GetText(TextFormat.Mof) + "\n";
     }
     return str;
 }
Exemplo n.º 2
0
 public static Hashtable GetAllWin32_ClassPropValuesIntoTable(WMI_ClassNames Win32_Class)
 {
     Hashtable hashtable = new Hashtable();
     ManagementObjectCollection instances = new ManagementClass(Win32_Class.ToString().Trim()).GetInstances();
     foreach (ManagementObject obj2 in instances)
     {
         PropertyDataCollection properties = obj2.Properties;
         foreach (PropertyData data in properties)
         {
             string key = data.Name.ToLower();
             if (!hashtable.ContainsKey(key)) hashtable.Add(key, data.Value);
         }
     }
     return hashtable;
 }
Exemplo n.º 3
0
 public static string GetAllConfigInfoFormComputer(WMI_ClassNames Win32_Class)
 {
     string str2;
     string str = "";
     try
     {
         ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + Win32_Class.ToString().Trim());
         foreach (ManagementObject obj2 in searcher.Get())
         {
             str = str + obj2.GetText(TextFormat.Mof) + "\n";
         }
         str2 = str;
     }
     catch (Exception exception)
     {
         throw new Exception("获取系统信息失败,请确认输入的对象和属性名正确:" + exception.Message);
     }
     return str2;
 }