コード例 #1
0
        private void EnumerateElements()
        {
            Log.Logger.Info("Entering EnumerateElements");
            try
            {
                ManagementBaseObject ooParams = InternalObject.GetMethodParameters("EnumerateElements");
                ManagementBaseObject ooRes    = InternalObject.InvokeMethod("EnumerateElements", ooParams, null);
                if (Convert.ToBoolean(ooRes["ReturnValue"]) == false)
                {
                    Log.Logger.Error("EnumerateElements return false.");
                    Log.Logger.Info("Leaving EnumerateElements.");
                    return;
                }

                ManagementBaseObject[] RetElements = (ManagementBaseObject[])ooRes.Properties["Elements"].Value;
                foreach (ManagementBaseObject obj in RetElements)
                {
                    BcdElement bcdelement = BcdElement.BcdElementFactory(obj);
                    this.elements.Add(bcdelement.TypeId, bcdelement);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Fatal(string.Format("Exception on WmiBcdstore.EnumerateObjects: {0}", ex.Message));
            }
            Log.Logger.Info("Leaving EnumerateElements.");
            return;
        }
コード例 #2
0
        public BcdElement GetElement(uint Type)
        {
            Log.Logger.Info("Entering GetElement");
            Log.Logger.Info(string.Format("Type : {0:X}", Type));
            ManagementBaseObject Element = null;

            try
            {
                System.Management.ManagementBaseObject inParams = null;
                inParams         = InternalObject.GetMethodParameters("GetElement");
                inParams["Type"] = ((System.UInt32)(Type));
                System.Management.ManagementBaseObject outParams = InternalObject.InvokeMethod("GetElement", inParams, null);
                if (true == System.Convert.ToBoolean(outParams.Properties["ReturnValue"].Value))
                {
                    Log.Logger.Info("Succeeded to call GetElement");
                    Element = ((System.Management.ManagementBaseObject)(outParams.Properties["Element"].Value));
                    Log.Logger.Info("Leaving GetElement");
                    return(BcdElement.BcdElementFactory(Element));
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Fatal(string.Format("Failed to Get Element with Type {0:x} with exception : {1}", Type, ex.Message));
            }
            Log.Logger.Info("Leaving GetElement with null");
            return(null);
        }