Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        internal static int OpenKey(IMSAdminBase adminBase, SafeMetadataHandle handle, string Path, MBKeyAccess AccessRequested, int TimeOut, out SafeMetadataHandle newHandle)
        {
            IntPtr handle2;
            int    num = adminBase.OpenKey(handle, Path, AccessRequested, TimeOut, out handle2);

            if (num == 0)
            {
                newHandle = new SafeMetadataHandle(handle2, adminBase);
            }
            else
            {
                newHandle = null;
            }
            return(num);
        }
        public MetabaseReader()
        {
            uint num;

            this.currentBufferSize = 0x400;
            lock (syncRoot)
            {
                if (adminBase == null)
                {
                    adminBase = (IMSAdminBase) new MSAdminBase();
                }
            }
            uint num2 = adminBase.OpenKey(0, "/LM", 1, 0x7530, out num);

            this.mdHandle = (int)num;
            if (num2 != 0)
            {
                throw FxTrace.Exception.AsError(new COMException(System.ServiceModel.Activation.SR.Hosting_MetabaseAccessError, (int)num2));
            }
            this.bufferHandle = SafeHGlobalHandleCritical.AllocHGlobal(this.currentBufferSize);
        }
        public MetabaseReader()
        {
            lock (syncRoot)
            {
                if (adminBase == null)
                {
                    adminBase = (IMSAdminBase) new MSAdminBase();
                }
            }

            uint handle;
            uint hResult = adminBase.OpenKey(MSAdminBase.METADATA_MASTER_ROOT_HANDLE, LMPath,
                                             MSAdminBase.METADATA_PERMISSION_READ, MSAdminBase.DEFAULT_METABASE_TIMEOUT, out handle);

            mdHandle = (int)handle;

            if (hResult != 0)
            {
                throw FxTrace.Exception.AsError(new COMException(SR.Hosting_MetabaseAccessError, (int)hResult));
            }

            bufferHandle = SafeHGlobalHandleCritical.AllocHGlobal(currentBufferSize);
        }