internal unsafe SubkeySnapshotEnumerator(StateSnapshot snapshot, IntPtr snapshotHandle, void *keyHandleWrapper)
 {
     Snapshot          = snapshot;
     _implState        = new PInvokeAPI.SubkeyIteratorState();
     _keyHandleWrapper = keyHandleWrapper;
     _isBeforeFirst    = true;
     PInvokeAPI.RawSubkeyView subkey_view = new PInvokeAPI.RawSubkeyView();
     PInvokeAPI.SubkeyIteratorState_Init(keyHandleWrapper, snapshotHandle, ref _implState, ref subkey_view);
     _currentSubkeySnapshot = new SubkeySnapshot(snapshot, subkey_view.subkey, subkey_view.version, subkey_view.data, subkey_view.IntSize);
 }
        /// <summary>
        /// Moves to next item in the enumeration.
        /// </summary>
        /// <returns>True if there is a next item.</returns>
        public unsafe bool MoveNext()
        {
            if (_isBeforeFirst)
            {
                _isBeforeFirst = false;
                return(_implState.currentStateBlock != null);
            }
            if (_implState.currentStateBlock == null)
            {
                return(false);
            }

            PInvokeAPI.RawSubkeyView subkey_view = new PInvokeAPI.RawSubkeyView();
            PInvokeAPI.SubkeyIteratorState_Advance(ref _implState, ref subkey_view);

            if (_implState.currentStateBlock == null)
            {
                return(false);
            }

            _currentSubkeySnapshot = new SubkeySnapshot(Snapshot, subkey_view.subkey, subkey_view.version, subkey_view.data, subkey_view.IntSize);
            return(true);
        }