void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    record.pbMDData   = IntPtr.Zero;
                    currentBufferSize = 0;

                    if (bufferHandle != null)
                    {
                        bufferHandle.Close();
                    }
                }

                int handleToClose = Interlocked.Exchange(ref mdHandle, 0);
                if (handleToClose != 0)
                {
                    adminBase.CloseKey((uint)handleToClose);
                }

                //Notice we cannot assign adminBase to NULL in Dispose, because
                //it could be shared by multiple instances of MetabaseReader.

                disposed = true;
            }
        }
Exemplo n.º 2
0
        /**
         * Test whether a key exists at the specified path.
         */
        public static bool TestKey(String keyPath)
        {
            bool found = false;

            try {
                IntPtr hMDHandle = IntPtr.Zero;
                baseInterface.OpenKey(METADATA_MASTER_ROOT_HANDLE, keyPath, METADATA_PERMISSION_READ, 20, out hMDHandle);
                baseInterface.CloseKey(hMDHandle);
                found = true;
            } catch (DirectoryNotFoundException) {
                // HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)
            }
            return(found);
        }
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             this.record.pbMDData   = IntPtr.Zero;
             this.currentBufferSize = 0;
             if (this.bufferHandle != null)
             {
                 this.bufferHandle.Close();
             }
         }
         int num = Interlocked.Exchange(ref this.mdHandle, 0);
         if (num != 0)
         {
             adminBase.CloseKey((uint)num);
         }
         this.disposed = true;
     }
 }