AGS.Editor.Utilities.OpenAGSRegistryKey C# (CSharp) Метод

OpenAGSRegistryKey() публичный статический Метод

public static OpenAGSRegistryKey ( ) : RegistryKey
Результат Microsoft.Win32.RegistryKey
        public static RegistryKey OpenAGSRegistryKey()
        {
            RegistryKey key;
            try
            {
                key = Registry.CurrentUser.CreateSubKey(AGSEditor.AGS_REGISTRY_KEY);
                if (key == null)
                {
                    Factory.GUIController.ShowMessage("Unable to access registry key: " + AGSEditor.AGS_REGISTRY_KEY, System.Windows.Forms.MessageBoxIcon.Warning);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                Factory.GUIController.ShowMessage("Unable to write to the registry. Your user preferences cannot be saved. Please contact your system administrator.\n\nError: " + ex.Message, System.Windows.Forms.MessageBoxIcon.Warning);
                key = null;
            }

            return key;
        }

Usage Example

Пример #1
0
        private void SaveRecentGamesList()
        {
            RegistryKey key = Utilities.OpenAGSRegistryKey();

            if (key == null)
            {
                Factory.GUIController.ShowMessage("Unable to access registry key: " + AGSEditor.AGS_REGISTRY_KEY, System.Windows.Forms.MessageBoxIcon.Warning);
            }
            else
            {
                int i = 0;
                foreach (RecentlyEditedGame game in _recentGames)
                {
                    key.SetValue("RecentPath" + i, game.DirectoryPath);
                    key.SetValue("RecentName" + i, game.GameName);
                    i++;
                }
                key.DeleteValue("RecentPath" + i, false);
                key.Close();
            }
        }