Globals.RegistryAccess.CloseReg C# (CSharp) Method

CloseReg() public method

Closes the Registry read access.
public CloseReg ( ) : void
return void
        public void CloseReg()
        {
            if (_isOpen)
            try
            {
                the_Reg.Close();
                _isOpen = false;
            }
            catch {}
        }

Usage Example

示例#1
0
        /// <summary>
        /// Adds a file to the Halo 2 recently used list
        /// </summary>
        /// <param name="pos">The position in which to add the fileName (0-9)</param>
        /// <param name="fileName">The location and name of the file</param>
        public static void AddRecentFile(int pos, string fileName)
        {
            int found = -1;
            int count = 0;
            string[] files = new string[10];
            // Load recently used files list
            RegistryAccess ra = new RegistryAccess(Registry.CurrentUser, RegPaths.Halo2RecentFiles);
            for (int i = 0; i < files.Length; i++)
            {
                files[i] = ra.getValue(i.ToString());
                if (files[i] != null) count++;
                if (files[i] == fileName) found = i;
            }
            ra.CloseReg();

            if (found == -1) found = count;
            if (found < pos)
            {
                int z = found;
                found = pos;
                pos = z;
            }

            for (int i = found; i > pos; i--)
                setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, i.ToString(), files[i-1]);
            setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, pos.ToString(), fileName);
        }
All Usage Examples Of Globals.RegistryAccess::CloseReg