Esempio n. 1
0
        public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)
        {
            IntPtr pUnk = IntPtr.Zero;

            try
            {
                pUnk = RuntimeEnvironment.GetRuntimeInterfaceImpl(clsid, riid);
                return(Marshal.GetObjectForIUnknown(pUnk));
            }
            finally
            {
                if (pUnk != IntPtr.Zero)
                {
                    Marshal.Release(pUnk);
                }
            }
        }
        public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)
        {
            IntPtr intPtr = IntPtr.Zero;
            object objectForIUnknown;

            try
            {
                intPtr            = RuntimeEnvironment.GetRuntimeInterfaceImpl(clsid, riid);
                objectForIUnknown = Marshal.GetObjectForIUnknown(intPtr);
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.Release(intPtr);
                }
            }
            return(objectForIUnknown);
        }
Esempio n. 3
0
 public static IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid)
 {
     return(RuntimeEnvironment.GetRuntimeInterfaceImpl(clsid, riid));
 }