Exemple #1
0
        static public String GetMethodDescription(String methName, ISWbemObject curObj)
        {
            try
            {
                ISWbemQualifier descrQual   = null;
                ISWbemMethod    verboseMeth = null;

                if (!curObj.Path_.IsClass)
                {
                    ISWbemObject classObj = WmiHelper.GetClassObject(curObj);
                    verboseMeth = classObj.Methods_.Item(methName, 0);
                }
                else
                {
                    verboseMeth = curObj.Methods_.Item(methName, 0);
                }

                descrQual = verboseMeth.Qualifiers_.Item("Description", 0);

                return(descrQual.get_Value().ToString());
            }
            catch (Exception)
            {
                //2880: removed message here
                return("");
            }
        }
Exemple #2
0
        static public String GetPropertyDescription(String propName, ISWbemObject curObj)
        {
            try
            {
                if (curObj == null)
                {
                    throw new ArgumentNullException("curObj");
                }
                ISWbemProperty verboseProp = null;

                if (!curObj.Path_.IsClass)
                {
                    ISWbemObject classObj = WmiHelper.GetClassObject(curObj);
                    verboseProp = classObj.Properties_.Item(propName, 0);
                }
                else
                {
                    verboseProp = curObj.Properties_.Item(propName, 0);
                }

                string          descr     = string.Empty;
                ISWbemQualifier descrQual = verboseProp.Qualifiers_.Item("Description", 0);

                descr = descrQual.get_Value().ToString();
                return(descr);
            }
            catch (Exception)
            {
                return("");
            }
        }
Exemple #3
0
        /// <summary>
        /// CheckPropertyQualifierExistence
        /// </summary>
        /// <param name="prop"> </param>
        /// <param name="qualName"> </param>
        static private bool CheckPropertyQualifierExistence(ISWbemProperty prop, String qualName)
        {
            ISWbemQualifierSet qualSet = prop.Qualifiers_;

            try
            {
                ISWbemQualifier qual = (ISWbemQualifier)qualSet.Item(qualName, 0);
                return(true);                   //previous statement didn't throw, so qualifier must be present
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// CheckObjectBoolQualifier
        /// </summary>
        /// <param name="obj"> </param>
        /// <param name="qualName"> </param>
        static private bool CheckObjectBoolQualifier(ISWbemObject obj, String qualName)
        {
            try
            {
                ISWbemQualifierSet qualSet = obj.Qualifiers_;
                ISWbemQualifier    qual    = (ISWbemQualifier)qualSet.Item(qualName, 0);

                return(Convert.ToBoolean(qual.get_Value()));
            }
            catch (Exception)
            {
                //NOTE that if the qualifier is not present, "Not found" will be returned
                //Return false in this case
                return(false);
            }
        }
Exemple #5
0
        public static String GetDisplayName(ISWbemObject obj)
        {
            try
            {
                ISWbemObject verboseObj = obj;

                if (!obj.Path_.IsClass)
                {
                    verboseObj = WmiHelper.GetClassObject(obj);
                }

                ISWbemQualifier dispName = verboseObj.Qualifiers_.Item("DisplayName", 0);
                return(dispName.get_Value().ToString());
            }
            catch (Exception)
            {
                return(String.Empty);
            }
        }
Exemple #6
0
        static public String GetClassDescription(ISWbemObject obj)
        {
            try
            {
                ISWbemObject verboseObj = obj;

                if (!obj.Path_.IsClass)
                {
                    verboseObj = WmiHelper.GetClassObject(obj);
                }

                ISWbemQualifier descrQual = verboseObj.Qualifiers_.Item("Description", 0);
                return(descrQual.get_Value().ToString());
            }
            catch (Exception)
            {
                return("");
            }
        }
Exemple #7
0
 static public bool IsValueMap(ISWbemProperty prop)
 {
     try
     {
         IEnumerator enumQuals = ((IEnumerable)(prop.Qualifiers_)).GetEnumerator();
         while (enumQuals.MoveNext())
         {
             ISWbemQualifier qual = (ISWbemQualifier)enumQuals.Current;
             if (qual.Name == "Values")
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }