Пример #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;
 }
Пример #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;
 }
Пример #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;
 }
Пример #4
0
 public static string GetWin32_ClassPropertyValueByName(WMI_ClassNames Win32_Class, string propertyName)
 {
     string key = propertyName.ToLower().Trim();
     Hashtable hashtable = GetAllWin32_ClassPropValuesIntoTable(Win32_Class);
     string str2 = null;
     if (hashtable.ContainsKey(key))
     {
         object obj2 = hashtable[key];
         if (obj2 != null) str2 = obj2.ToString();
     }
     return str2;
 }