Ejemplo n.º 1
0
        /// <summary>
        /// Get a single property from a class.
        /// </summary>
        /// <param name="wmiclass">WMI class.</param>
        /// <param name="property">Property inside the class.</param>
        /// <param name="condition">Condition the property needs to match.</param>
        /// <param name="scope">WMI scope.</param>
        /// <returns>WMI property containing property name and value.</returns>
        public static WmiProperty PropertyQuery(string wmiclass, string property, string condition, ManagementScope scope = null)
        {
            ManagementObjectCollection objectCollection = GetObjectCollection(wmiclass, property, condition, scope);
            WmiClassCollection         classCollection  = ParseObjectCollection(objectCollection);

            foreach (WmiClass classObject in classCollection)
            {
                foreach (WmiProperty classProperty in classObject.Properties)
                {
                    return(classProperty);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        // Token: 0x0600000B RID: 11 RVA: 0x00002268 File Offset: 0x00000468
        public static WmiProperty PropertyQuery(string wmiclass, string property, string condition, ManagementScope scope = null)
        {
            ManagementObjectCollection objectCollection   = Wmi.GetObjectCollection(wmiclass, property, condition, scope);
            WmiClassCollection         wmiClassCollection = Wmi.ParseObjectCollection(objectCollection);

            foreach (WmiClass wmiClass in wmiClassCollection)
            {
                WmiProperty[] properties = wmiClass.Properties;
                int           num        = 0;
                if (num < properties.Length)
                {
                    return(properties[num]);
                }
            }
            return(null);
        }