예제 #1
0
파일: RotHelper.cs 프로젝트: persadewh/xcad
        public static void UnregisterComObject(int id)
        {
            IBindCtx            context = null;
            IRunningObjectTable rot     = null;

            CreateBindCtx(0, out context);
            context.GetRunningObjectTable(out rot);

            try
            {
                rot.Revoke(id);
            }
            finally
            {
                if (rot != null)
                {
                    while (Marshal.ReleaseComObject(rot) > 0)
                    {
                        ;
                    }
                }

                if (context != null)
                {
                    while (Marshal.ReleaseComObject(context) > 0)
                    {
                        ;
                    }
                }
            }
        }
예제 #2
0
        public static bool RemoveGraphFromRot(ref int cookie)
        {
            IRunningObjectTable rot = null;

            try {
                int hr = GetRunningObjectTable(0, out rot);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                rot.Revoke(cookie);
                cookie = 0;
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                if (rot != null)
                {
                    Marshal.ReleaseComObject(rot);
                }
                rot = null;
            }
        }
예제 #3
0
        /// <summary>Removes the graph from the running object table.</summary>
        /// <param name="cookie">The cookie value for the registered graph.</param>
        private static void RemoveGraphFromRot(RunningObjectTableCookie cookie)
        {
            if (!cookie.IsValid)
            {
                throw new ArgumentException("cookie");
            }
            IRunningObjectTable rot = null;

            try
            {
                // Get the running object table and revoke the cookie
                rot = GetRunningObjectTable(0);
                rot.Revoke(cookie.Value);
                cookie.IsValid = false;
            }
            finally
            {
                // Release the ROT
                if (rot != null)
                {
                    while (Marshal.ReleaseComObject(rot) > 0)
                    {
                        ;
                    }
                }
            }
        }
예제 #4
0
        public static void ROTUnregister(ref int cookie)
        {
            // Revoke any existing file moniker. See Brockschmidt, Inside Ole 2nd ed. p988
            IRunningObjectTable rot = GetROT();

            if (0 != cookie)
            {
                rot.Revoke(cookie);
                cookie = 0;
            }
        }
예제 #5
0
 public void Dispose()
 {
     if (this.m_cookie != 0)
     {
         GC.SuppressFinalize(this);
         IRunningObjectTable pprot = null;
         DsError.ThrowExceptionForHR(GetRunningObjectTable(0, out pprot));
         try
         {
             pprot.Revoke(this.m_cookie);
             this.m_cookie = 0;
         }
         finally
         {
             Marshal.ReleaseComObject(pprot);
             pprot = null;
         }
     }
 }
        void Dispose(bool disposing)
        {
            if (isDisposed)
            {
                return;
            }
            isDisposed = true;

            try
            {
                rot.Revoke(hRotEntry);
            }
            catch (Exception) when(!disposing)
            {
                // no-op, on finalizer
            }
            this.rot    = null;
            this.Target = null;
        }
예제 #7
0
파일: FileIsInUse.cs 프로젝트: aata/szotar
        private void Revoke()
        {
            if (moniker == null)
            {
                return;
            }

            if (cookie.HasValue)
            {
                IRunningObjectTable table = GetTable();
                if (table != null)
                {
                    try {
                        table.Revoke(cookie.Value);
                    } catch (COMException) {
                        // Realistically, there is no point trying to handle this exception.
                    }
                }
            }
        }
예제 #8
0
        public static bool RemoveGraphFromRot(ref int pdwRegister)
        {
            IRunningObjectTable rot = null;

            try
            {
                Marshal.ThrowExceptionForHR(GetRunningObjectTable(0, out rot));
                rot.Revoke(pdwRegister);
                pdwRegister = 0;
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (rot != null)
                {
                    Marshal.ReleaseComObject(rot);
                }
            }
        }
예제 #9
0
        public void Dispose()
        {
            if (m_cookie != 0)
            {
                GC.SuppressFinalize(this);
                IRunningObjectTable rot = null;

                // Get a pointer to the running object table
                int hr = GetRunningObjectTable(0, out rot);
                new HRESULT(hr).Throw();

                try
                {
                    // Remove our entry
                    rot.Revoke(m_cookie);
                    m_cookie = 0;
                }
                finally
                {
                    Marshal.ReleaseComObject(rot);
                    rot = null;
                }
            }
        }