예제 #1
0
        private static void StopRegistryMonitor()
        {
            // Cleanup allocated handles
            s_stopMonitoring = true;

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

            if (s_waitHandle != null)
            {
                s_waitHandle.Unregister(s_notifyEvent);
                s_waitHandle = null;
            }

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

            Trace(TAG_DEBUG_VERBOSE, "Registry monitoring stopped.");
        }
예제 #2
0
        protected RegistryDataKey(string fullPath, SafeRegistryHandle regHandle)
        {
            ISpRegDataKey  regKey  = (ISpRegDataKey) new SpDataKey();
            SAPIErrorCodes hresult = (SAPIErrorCodes)regKey.SetKey(regHandle, false);

            regHandle?.Close();
            if ((hresult != SAPIErrorCodes.S_OK) && (hresult != SAPIErrorCodes.SPERR_ALREADY_INITIALIZED))
            {
                throw new InvalidOperationException();
            }

            _sapiRegKey     = regKey;
            _sKeyId         = fullPath;
            _disposeSapiKey = true;
        }
예제 #3
0
        public void Close(RegistryKey rkey)
        {
            if (!IsHandleValid(rkey))
            {
                return;
            }
            SafeRegistryHandle safe_handle = rkey.Handle;

            if (safe_handle != null)
            {
                // closes the unmanaged pointer for us.
                safe_handle.Close();
                return;
            }
            IntPtr handle = GetHandle(rkey);

            RegCloseKey(handle);
        }