internal __ComObject(IntPtr pItf, ComInteropProxy p) { proxy = p; InitializeApartmentDetails(); Guid iid = IID_IUnknown; int hr = Marshal.QueryInterface(pItf, ref iid, out iunknown); Marshal.ThrowExceptionForHR(hr); }
public static object GetObjectForIUnknown(IntPtr pUnk) { object obj = GetObjectForCCW(pUnk); // was not a CCW if (obj == null) { ComInteropProxy proxy = ComInteropProxy.GetProxy(pUnk, typeof(__ComObject)); obj = proxy.GetTransparentProxy(); } return(obj); }
public static object GetObjectForIUnknown(IntPtr pUnk) { #if !MOBILE object obj = GetObjectForCCW(pUnk); // was not a CCW if (obj == null) { ComInteropProxy proxy = ComInteropProxy.GetProxy(pUnk, typeof(__ComObject)); obj = proxy.GetTransparentProxy(); } return(obj); #else throw new NotImplementedException(); #endif }
public static object GetTypedObjectForIUnknown(IntPtr pUnk, Type t) { ComInteropProxy proxy = new ComInteropProxy(pUnk, t); __ComObject co = (__ComObject)proxy.GetTransparentProxy(); foreach (Type itf in t.GetInterfaces()) { if ((itf.Attributes & TypeAttributes.Import) == TypeAttributes.Import) { if (co.GetInterface(itf) == IntPtr.Zero) { return(null); } } } return(co); }
public static object CreateWrapperOfType(object o, Type t) { __ComObject co = o as __ComObject; if (co == null) { throw new ArgumentException("o must derive from __ComObject", "o"); } if (t == null) { throw new ArgumentNullException("t"); } Type[] itfs = o.GetType().GetInterfaces(); foreach (Type itf in itfs) { if (itf.IsImport && co.GetInterface(itf) == IntPtr.Zero) { throw new InvalidCastException(); } } return(ComInteropProxy.GetProxy(co.IUnknown, t).GetTransparentProxy()); }
internal void Initialize(IntPtr pUnk, ComInteropProxy p) { proxy = p; InitializeApartmentDetails(); iunknown = pUnk; }