Example #1
0
        private void Update()
        {
            //Update info text
            string info = "";

            try
            {
                bool hasEntry = RegisterHelper.HasEntryWithCurrentPath();
                if (hasEntry)
                {
                    info += "Registry entry is set:\n\n";

                    string entryPath = RegisterHelper.GetRegistryPath();
                    string entryKey  = RegisterHelper.GetRegistryKey();

                    if (entryPath != null && entryPath.Length > 0)
                    {
                        info += "Path: " + entryPath + "\n";
                    }
                    if (entryKey != null && entryKey.Length > 0)
                    {
                        info += "Entry: " + entryKey + "\n";
                    }
                }
                else
                {
                    info += "Registry entry isn't set";
                }
            } catch (Exception e)
            {
                info = "";
            }

            InfoTextBox.Text = info;
        }
Example #2
0
        private static void InitializeRegistryEntry()
        {
            //Initialize shortcut helper
            ShortcutHelper shortcut = new ShortcutHelper();

            RegisterHelper.shortcut = shortcut;

            //Initialize registry entry if needed
            try
            {
                ConfigStorage configStorage = ConfigStorage.Global;
                if (configStorage == null)
                {
                    return;
                }

                string redirectPath = configStorage.GetValue(Config.ConfigRedirectRegistryEntryKey, Config.ConfigDefaultRedirectRegistryEntryValue);
                if (redirectPath != null)
                {
                    redirectPath = redirectPath.Trim();
                }
                if (redirectPath != null && redirectPath.Length > 0)
                {
                    string fullRedirectPath = FileHelper.GetByRelativePath(redirectPath);
                    if (fullRedirectPath != null)
                    {
                        RegisterHelper.SetRedirectPath(fullRedirectPath, false);
                    }
                }

                bool setRegistryEntry = configStorage.GetBool(Config.ConfigEnableRegistryEntryKey, Config.ConfigDefaultEnableRegistryEntryValue);

                if (setRegistryEntry)
                {
                    bool hasEntry = RegisterHelper.HasEntryWithCurrentPath();
                    if (!hasEntry)
                    {
                        RegisterHelper.PutEntry();
                    }
                }

                if (!setRegistryEntry)
                {
                    bool hasEntry = RegisterHelper.HasEntry();
                    if (hasEntry)
                    {
                        RegisterHelper.RemoveEntry();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }