コード例 #1
0
 int WbemNative.IWbemServices.PutInstance(
     WbemNative.IWbemClassObject pInst,
     Int32 lFlags,
     WbemNative.IWbemContext wbemContext,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
コード例 #2
0
 int WbemNative.IWbemServices.PutClassAsync(
     WbemNative.IWbemClassObject wbemObject,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemObjectSink wbemSink)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
コード例 #3
0
        int WbemNative.IWbemServices.PutInstanceAsync(
            WbemNative.IWbemClassObject wbemObject,
            Int32 lFlags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemObjectSink wbemSink
            )
        {
            if (wbemObject == null || wbemContext == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity() : null)
            {
                try
                {
                    object val   = null;
                    int    type  = 0;
                    int    favor = 0;
                    WbemException.ThrowIfFail(wbemObject.Get("__CLASS", 0, ref val, ref type, ref favor));
                    string className = (string)val;
                    ServiceModelActivity.Start(activity, SR.GetString(SR.WmiPutInstance, string.IsNullOrEmpty(className) ? string.Empty : className), ActivityType.WmiPutInstance);

                    ParameterContext parms        = new ParameterContext(className, this.wbemServices, wbemContext, wbemSink);
                    WbemInstance     wbemInstance = new WbemInstance(parms, wbemObject);
                    IWmiProvider     wmiProvider  = this.GetProvider(parms.ClassName);
                    if (wmiProvider.PutInstance(new InstanceContext(wbemInstance)))
                    {
                        wbemInstance.Indicate();
                    }

                    WbemException.ThrowIfFail(wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                                                 (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR, null, null));
                }
                catch (WbemException e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiPutInstanceFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       e.ErrorCode, null, null);
                    return(e.ErrorCode);
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiPutInstanceFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null);
                    return((int)WbemNative.WbemStatus.WBEM_E_FAILED);
                }
                finally
                {
                    Marshal.ReleaseComObject(wbemSink);
                }
            }
            return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR);
        }
コード例 #4
0
 internal void SetProperty(string name, object val)
 {
     if (val != null)
     {
         WbemNative.CIMTYPE cimtype = WbemNative.CIMTYPE.CIM_EMPTY;
         if (val is DateTime)
         {
             val = ((DateTime)val).ToString("yyyyMMddhhmmss.ffffff", CultureInfo.InvariantCulture) + "+000";
         }
         else if (val is TimeSpan)
         {
             TimeSpan span = (TimeSpan)val;
             long     num  = (span.Ticks % 0x3e8L) / 10L;
             val = string.Format(CultureInfo.InvariantCulture, "{0:00000000}{1:00}{2:00}{3:00}.{4:000}{5:000}:000", new object[] { span.Days, span.Hours, span.Minutes, span.Seconds, span.Milliseconds, num });
         }
         else if (val is WbemProvider.InstanceContext)
         {
             WbemProvider.InstanceContext context = (WbemProvider.InstanceContext)val;
             val = context.WbemObject;
         }
         else if (val is Array)
         {
             Array array = (Array)val;
             if ((array.GetLength(0) > 0) && (array.GetValue(0) is WbemProvider.InstanceContext))
             {
                 WbemNative.IWbemClassObject[] objArray = new WbemNative.IWbemClassObject[array.GetLength(0)];
                 for (int i = 0; i < objArray.Length; i++)
                 {
                     objArray[i] = ((WbemProvider.InstanceContext)array.GetValue(i)).WbemObject;
                 }
                 val = objArray;
             }
         }
         else if (val is long)
         {
             val     = ((long)val).ToString(CultureInfo.InvariantCulture);
             cimtype = WbemNative.CIMTYPE.CIM_SINT64;
         }
         int hr = this.wbemObject.Put(name, 0, ref val, (int)cimtype);
         if ((-2147217403 == hr) || (-2147217406 == hr))
         {
             EventLogEventId id;
             if (-2147217403 == hr)
             {
                 id = (EventLogEventId)(-1073610732);
             }
             else
             {
                 id = (EventLogEventId)(-1073610731);
             }
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, id, new string[] { this.className, name, val.GetType().ToString() });
         }
         else
         {
             WbemException.ThrowIfFail(hr);
         }
     }
 }
コード例 #5
0
 int WbemNative.IWbemServices.GetObject(
     string objectPath,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     ref WbemNative.IWbemClassObject wbemObject,
     IntPtr wbemResult
     )
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
コード例 #6
0
 int WbemNative.IWbemServices.ExecMethod(
     string objectPath,
     string methodName,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemClassObject wbemInParams,
     ref WbemNative.IWbemClassObject wbemOutParams,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
コード例 #7
0
 internal MethodContext(WbemProvider.ParameterContext parms, string methodName, WbemNative.IWbemClassObject wbemInParms, WbemProvider.WbemInstance wbemInstance)
 {
     this.parms       = parms;
     this.methodName  = methodName;
     this.wbemInParms = wbemInParms;
     this.instance    = new WbemProvider.InstanceContext(wbemInstance);
     WbemNative.IWbemClassObject ppObject = null;
     WbemException.ThrowIfFail(parms.WbemServices.GetObject(parms.ClassName, 0, parms.WbemContext, ref ppObject, IntPtr.Zero));
     WbemNative.IWbemClassObject ppOutSignature = null;
     WbemException.ThrowIfFail(ppObject.GetMethod(methodName, 0, IntPtr.Zero, out ppOutSignature));
     WbemException.ThrowIfFail(ppOutSignature.SpawnInstance(0, out this.wbemOutParms));
 }
コード例 #8
0
 internal WbemInstance(WbemProvider.ParameterContext parms, string className)
 {
     this.parms = parms;
     if (string.IsNullOrEmpty(className))
     {
         className = parms.ClassName;
     }
     this.className = className;
     WbemNative.IWbemClassObject ppObject = null;
     WbemException.ThrowIfFail(parms.WbemServices.GetObject(className, 0, parms.WbemContext, ref ppObject, IntPtr.Zero));
     if (ppObject != null)
     {
         WbemException.ThrowIfFail(ppObject.SpawnInstance(0, out this.wbemObject));
     }
 }
コード例 #9
0
            internal WbemInstance(ParameterContext parms, string className)
            {
                this.parms = parms;
                if (String.IsNullOrEmpty(className))
                {
                    className = parms.ClassName;
                }
                this.className = className;
                WbemNative.IWbemClassObject tempObj = null;
                WbemException.ThrowIfFail(
                    parms.WbemServices.GetObject(className, 0, parms.WbemContext, ref tempObj, IntPtr.Zero)
                    );


                if (null != tempObj)
                {
                    WbemException.ThrowIfFail(tempObj.SpawnInstance(0, out this.wbemObject));
                }
            }
コード例 #10
0
 int WbemNative.IWbemServices.PutInstanceAsync(WbemNative.IWbemClassObject wbemObject, int lFlags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     if (((wbemObject == null) || (wbemContext == null)) || ((wbemSink == null) || (this.wbemServices == null)))
     {
         return(-2147217400);
     }
     using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity() : null)
     {
         try
         {
             WbemException.ThrowIfFail(wbemObject.Get("__CLASS", 0, null, 0, 0));
             string str = (string)pVal;
             ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("WmiPutInstance", new object[] { string.IsNullOrEmpty(str) ? string.Empty : str }), ActivityType.WmiPutInstance);
             ParameterContext parms        = new ParameterContext(str, this.wbemServices, wbemContext, wbemSink);
             WbemInstance     wbemInstance = new WbemInstance(parms, wbemObject);
             if (this.GetProvider(parms.ClassName).PutInstance(new InstanceContext(wbemInstance)))
             {
                 wbemInstance.Indicate();
             }
             WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null));
         }
         catch (WbemException exception)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610739), new string[] { TraceUtility.CreateSourceString(this), exception.ToString() });
             wbemSink.SetStatus(0, exception.ErrorCode, null, null);
             return(exception.ErrorCode);
         }
         catch (Exception exception2)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610739), new string[] { TraceUtility.CreateSourceString(this), exception2.ToString() });
             wbemSink.SetStatus(0, -2147217407, null, null);
             return(-2147217407);
         }
         finally
         {
             Marshal.ReleaseComObject(wbemSink);
         }
     }
     return(0);
 }
コード例 #11
0
 internal MethodContext(WbemProvider.ParameterContext parms, string methodName, WbemNative.IWbemClassObject wbemInParms, WbemProvider.WbemInstance wbemInstance)
 {
     this.parms = parms;
     this.methodName = methodName;
     this.wbemInParms = wbemInParms;
     this.instance = new WbemProvider.InstanceContext(wbemInstance);
     WbemNative.IWbemClassObject ppObject = null;
     WbemException.ThrowIfFail(parms.WbemServices.GetObject(parms.ClassName, 0, parms.WbemContext, ref ppObject, IntPtr.Zero));
     WbemNative.IWbemClassObject ppOutSignature = null;
     WbemException.ThrowIfFail(ppObject.GetMethod(methodName, 0, IntPtr.Zero, out ppOutSignature));
     WbemException.ThrowIfFail(ppOutSignature.SpawnInstance(0, out this.wbemOutParms));
 }
コード例 #12
0
            internal void SetProperty(string name, object val)
            {
                Fx.Assert(null != this.wbemObject, name + " may not be available to WMI");
                if (null != val)
                {
                    WbemNative.CIMTYPE type = 0;
                    if (val is DateTime)
                    {
                        val = ((DateTime)val).ToString("yyyyMMddhhmmss.ffffff", CultureInfo.InvariantCulture) + "+000";
                    }
                    else if (val is TimeSpan)
                    {
                        TimeSpan ts = (TimeSpan)val;
                        long microSeconds = (ts.Ticks % 1000) / 10;
                        val = string.Format(CultureInfo.InvariantCulture, "{0:00000000}{1:00}{2:00}{3:00}.{4:000}{5:000}:000",
                            new object[] { ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, microSeconds });
                    }
                    else if (val is InstanceContext)
                    {
                        InstanceContext inst = (InstanceContext)val;
                        val = inst.WbemObject;
                    }
                    else if (val is Array)
                    {
                        Array objs = (Array)val;
                        if (objs.GetLength(0) > 0 && objs.GetValue(0) is InstanceContext)
                        {
                            WbemNative.IWbemClassObject[] insts = new WbemNative.IWbemClassObject[objs.GetLength(0)];
                            for (int i = 0; i < insts.Length; ++i)
                            {
                                insts[i] = ((InstanceContext)objs.GetValue(i)).WbemObject;
                            }
                            val = insts;
                        }
                    }
                    else if (val is Int64)
                    {
                        val = ((Int64)val).ToString(CultureInfo.InvariantCulture);
                        type = WbemNative.CIMTYPE.CIM_SINT64;
                    }

                    int hResult = this.wbemObject.Put(name, 0, ref val, (int)type);
                    if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult || (int)WbemNative.WbemStatus.WBEM_E_NOT_FOUND == hResult)
                    {
                        //This would be most likely a product bug (somebody changed type without updating MOF), improper installation or tampering with MOF
                        System.Runtime.Diagnostics.EventLogEventId eventId;
                        if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult)
                        {
                            eventId = System.Runtime.Diagnostics.EventLogEventId.WmiAdminTypeMismatch;
                        }
                        else
                        {
                            eventId = System.Runtime.Diagnostics.EventLogEventId.WmiPropertyMissing;
                        }
                        DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                            (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                            (uint)eventId,
                            this.className,
                            name,
                            val.GetType().ToString());
                    }
                    else
                    {
                        WbemException.ThrowIfFail(hResult);
                    }
                }
            }
コード例 #13
0
            internal void SetProperty(string name, object val)
            {
                Fx.Assert(null != this.wbemObject, name + " may not be available to WMI");
                if (null != val)
                {
                    WbemNative.CIMTYPE type = 0;
                    if (val is DateTime)
                    {
                        val = ((DateTime)val).ToString("yyyyMMddhhmmss.ffffff", CultureInfo.InvariantCulture) + "+000";
                    }
                    else if (val is TimeSpan)
                    {
                        TimeSpan ts           = (TimeSpan)val;
                        long     microSeconds = (ts.Ticks % 1000) / 10;
                        val = string.Format(CultureInfo.InvariantCulture, "{0:00000000}{1:00}{2:00}{3:00}.{4:000}{5:000}:000",
                                            new object[] { ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, microSeconds });
                    }
                    else if (val is InstanceContext)
                    {
                        InstanceContext inst = (InstanceContext)val;
                        val = inst.WbemObject;
                    }
                    else if (val is Array)
                    {
                        Array objs = (Array)val;
                        if (objs.GetLength(0) > 0 && objs.GetValue(0) is InstanceContext)
                        {
                            WbemNative.IWbemClassObject[] insts = new WbemNative.IWbemClassObject[objs.GetLength(0)];
                            for (int i = 0; i < insts.Length; ++i)
                            {
                                insts[i] = ((InstanceContext)objs.GetValue(i)).WbemObject;
                            }
                            val = insts;
                        }
                    }
                    else if (val is Int64)
                    {
                        val  = ((Int64)val).ToString(CultureInfo.InvariantCulture);
                        type = WbemNative.CIMTYPE.CIM_SINT64;
                    }

                    int hResult = this.wbemObject.Put(name, 0, ref val, (int)type);
                    if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult || (int)WbemNative.WbemStatus.WBEM_E_NOT_FOUND == hResult)
                    {
                        //This would be most likely a product bug (somebody changed type without updating MOF), improper installation or tampering with MOF
                        System.Runtime.Diagnostics.EventLogEventId eventId;
                        if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult)
                        {
                            eventId = System.Runtime.Diagnostics.EventLogEventId.WmiAdminTypeMismatch;
                        }
                        else
                        {
                            eventId = System.Runtime.Diagnostics.EventLogEventId.WmiPropertyMissing;
                        }
                        DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                            (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                            (uint)eventId,
                                                            this.className,
                                                            name,
                                                            val.GetType().ToString());
                    }
                    else
                    {
                        WbemException.ThrowIfFail(hResult);
                    }
                }
            }
コード例 #14
0
 internal WbemInstance(ParameterContext parms, WbemNative.IWbemClassObject wbemObject)
 {
     this.parms      = parms;
     this.wbemObject = wbemObject;
 }
コード例 #15
0
        int WbemNative.IWbemServices.ExecMethodAsync(
            string objectPath,
            string methodName,
            Int32 flags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemClassObject wbemInParams,
            WbemNative.IWbemObjectSink wbemSink)
        {
            if (wbemContext == null || wbemInParams == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            int result = (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR;

            try
            {
                ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
                ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
                WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);

                MethodContext methodContext = new MethodContext(parms, methodName, wbemInParams, wbemInstance);
                IWmiProvider  wmiProvider   = this.GetProvider(parms.ClassName);
                if (!wmiProvider.InvokeMethod(methodContext))
                {
                    result = (int)WbemNative.WbemStatus.WBEM_E_NOT_FOUND;
                }

                WbemException.ThrowIfFail(wbemSink.SetStatus(
                                              (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                              (int)result,
                                              null,
                                              null));
            }
            catch (WbemException e)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecMethodFailed,
                                                    e.ToString());
                result = e.ErrorCode;
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   result, null, null);
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecMethodFailed,
                                                    e.ToString());
                result = (int)WbemNative.WbemStatus.WBEM_E_FAILED;
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   (int)result, null, null);
            }
            finally
            {
                Marshal.ReleaseComObject(wbemSink);
            }
            return(result);
        }
コード例 #16
0
 int WbemNative.IWbemServices.GetObject(string objectPath, int flags, WbemNative.IWbemContext wbemContext, ref WbemNative.IWbemClassObject wbemObject, IntPtr wbemResult)
 {
     return(-2147217396);
 }
コード例 #17
0
 int WbemNative.IWbemServices.PutClass(WbemNative.IWbemClassObject wbemObject, int flags, WbemNative.IWbemContext wbemContext, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }
コード例 #18
0
        int WbemNative.IWbemServices.ExecMethodAsync(string objectPath, string methodName, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemClassObject wbemInParams, WbemNative.IWbemObjectSink wbemSink)
        {
            if (((wbemContext == null) || (wbemInParams == null)) || ((wbemSink == null) || (this.wbemServices == null)))
            {
                return(-2147217400);
            }
            int hResult = 0;

            try
            {
                ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
                ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
                WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);
                MethodContext    method       = new MethodContext(parms, methodName, wbemInParams, wbemInstance);
                if (!this.GetProvider(parms.ClassName).InvokeMethod(method))
                {
                    hResult = -2147217406;
                }
                WbemException.ThrowIfFail(wbemSink.SetStatus(0, hResult, null, null));
            }
            catch (WbemException exception)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610735), new string[] { exception.ToString() });
                hResult = exception.ErrorCode;
                wbemSink.SetStatus(0, hResult, null, null);
            }
            catch (Exception exception2)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610735), new string[] { exception2.ToString() });
                hResult = -2147217407;
                wbemSink.SetStatus(0, hResult, null, null);
            }
            finally
            {
                Marshal.ReleaseComObject(wbemSink);
            }
            return(hResult);
        }
コード例 #19
0
 internal WbemInstance(WbemProvider.ParameterContext parms, WbemNative.IWbemClassObject wbemObject)
 {
     this.parms = parms;
     this.wbemObject = wbemObject;
 }
コード例 #20
0
 int WbemNative.IWbemServices.PutClassAsync(WbemNative.IWbemClassObject wbemObject, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     return(-2147217396);
 }
コード例 #21
0
 int WbemNative.IWbemServices.PutInstance(WbemNative.IWbemClassObject pInst, int lFlags, WbemNative.IWbemContext wbemContext, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }
コード例 #22
0
 internal void SetProperty(string name, object val)
 {
     if (val != null)
     {
         WbemNative.CIMTYPE cimtype = WbemNative.CIMTYPE.CIM_EMPTY;
         if (val is DateTime)
         {
             val = ((DateTime) val).ToString("yyyyMMddhhmmss.ffffff", CultureInfo.InvariantCulture) + "+000";
         }
         else if (val is TimeSpan)
         {
             TimeSpan span = (TimeSpan) val;
             long num = (span.Ticks % 0x3e8L) / 10L;
             val = string.Format(CultureInfo.InvariantCulture, "{0:00000000}{1:00}{2:00}{3:00}.{4:000}{5:000}:000", new object[] { span.Days, span.Hours, span.Minutes, span.Seconds, span.Milliseconds, num });
         }
         else if (val is WbemProvider.InstanceContext)
         {
             WbemProvider.InstanceContext context = (WbemProvider.InstanceContext) val;
             val = context.WbemObject;
         }
         else if (val is Array)
         {
             Array array = (Array) val;
             if ((array.GetLength(0) > 0) && (array.GetValue(0) is WbemProvider.InstanceContext))
             {
                 WbemNative.IWbemClassObject[] objArray = new WbemNative.IWbemClassObject[array.GetLength(0)];
                 for (int i = 0; i < objArray.Length; i++)
                 {
                     objArray[i] = ((WbemProvider.InstanceContext) array.GetValue(i)).WbemObject;
                 }
                 val = objArray;
             }
         }
         else if (val is long)
         {
             val = ((long) val).ToString(CultureInfo.InvariantCulture);
             cimtype = WbemNative.CIMTYPE.CIM_SINT64;
         }
         int hr = this.wbemObject.Put(name, 0, ref val, (int) cimtype);
         if ((-2147217403 == hr) || (-2147217406 == hr))
         {
             EventLogEventId id;
             if (-2147217403 == hr)
             {
                 id = (EventLogEventId) (-1073610732);
             }
             else
             {
                 id = (EventLogEventId) (-1073610731);
             }
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, id, new string[] { this.className, name, val.GetType().ToString() });
         }
         else
         {
             WbemException.ThrowIfFail(hr);
         }
     }
 }
コード例 #23
0
 int WbemNative.IWbemServices.ExecMethod(string objectPath, string methodName, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemClassObject wbemInParams, ref WbemNative.IWbemClassObject wbemOutParams, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }