internal ParameterContext(string className, WbemNative.IWbemServices wbemServices, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink) { this.className = className; this.wbemServices = wbemServices; this.wbemContext = wbemContext; this.wbemSink = wbemSink; }
void RelocateWbemServicesRCWToMTA(object comObject) { IntPtr pUnk = Marshal.GetIUnknownForObject(comObject); Marshal.ReleaseComObject(comObject); this.wbemServices = (WbemNative.IWbemServices)Marshal.GetObjectForIUnknown(pUnk); Marshal.Release(pUnk); }
int WbemNative.IWbemServices.OpenNamespace( string nameSpace, Int32 flags, WbemNative.IWbemContext wbemContext, ref WbemNative.IWbemServices wbemServices, IntPtr wbemCallResult ) { return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED); }
int WbemNative.IWbemProviderInit.Initialize( string wszUser, Int32 lFlags, string wszNamespace, string wszLocale, WbemNative.IWbemServices wbemServices, WbemNative.IWbemContext wbemContext, WbemNative.IWbemProviderInitSink wbemSink ) { if (wbemServices == null || wbemContext == null || wbemSink == null) { return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER); } try { MTAExecute(new WaitCallback(this.RelocateWbemServicesRCWToMTA), wbemServices); wbemSink.SetStatus((int)WbemNative.tag_WBEM_EXTRA_RETURN_CODES.WBEM_S_INITIALIZED, 0); } catch (WbemException e) { wbemSink.SetStatus(e.ErrorCode, 0); return(e.ErrorCode); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception) { wbemSink.SetStatus((int)WbemNative.WbemStatus.WBEM_E_FAILED, 0); return((int)WbemNative.WbemStatus.WBEM_E_FAILED); } finally { // WMI relies on destructor of this interface to perform certain task // explicitly release this so that the GC won't hold on to the ref of // this after the function Marshal.ReleaseComObject(wbemSink); } return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR); }
private void RelocateWbemServicesRCWToMTA(object comObject) { IntPtr iUnknownForObject = Marshal.GetIUnknownForObject(comObject); Marshal.ReleaseComObject(comObject); this.wbemServices = (WbemNative.IWbemServices) Marshal.GetObjectForIUnknown(iUnknownForObject); Marshal.Release(iUnknownForObject); }
int WbemNative.IWbemServices.OpenNamespace(string nameSpace, int flags, WbemNative.IWbemContext wbemContext, ref WbemNative.IWbemServices wbemServices, IntPtr wbemCallResult) { return(-2147217396); }
int WbemNative.IWbemProviderInit.Initialize(string wszUser, int lFlags, string wszNamespace, string wszLocale, WbemNative.IWbemServices wbemServices, WbemNative.IWbemContext wbemContext, WbemNative.IWbemProviderInitSink wbemSink) { if (((wbemServices == null) || (wbemContext == null)) || (wbemSink == null)) { return(-2147217400); } try { MTAExecute(new WaitCallback(this.RelocateWbemServicesRCWToMTA), wbemServices); wbemSink.SetStatus(0, 0); } catch (WbemException exception) { wbemSink.SetStatus(exception.ErrorCode, 0); return(exception.ErrorCode); } catch (Exception) { wbemSink.SetStatus(-2147217407, 0); return(-2147217407); } finally { Marshal.ReleaseComObject(wbemSink); } return(0); }