예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
        }
예제 #4
0
        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);
        }
예제 #5
0
        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());
        }
예제 #6
0
 internal void Initialize(IntPtr pUnk, ComInteropProxy p)
 {
     proxy = p;
     InitializeApartmentDetails();
     iunknown = pUnk;
 }